For the complete documentation index, see llms.txt. This page is also available as Markdown.

趋势:探索

按关键词、日期范围和分类提取 Google Trends 数据。API 支持多种搜索类型和过滤。

google_trends_explore source 旨在检索 Google Trends 结果。

请求示例

在此示例中,我们发起请求以获取某个搜索词的趋势结果 adidas 介于 2021 年 1 月 1 日和 2022 年 2 月 2 日之间,并将类别设为“艺术与娱乐”(类别 ID: 3).

curl 'https://realtime.oxylabs.io/v1/queries' \\
--user 'USERNAME:PASSWORD' \\
-H 'Content-Type: application/json' \\
-d '{
        "source": "google_trends_explore",
        "query": "adidas",
        "context": [
            {"key": "date_from", "value": "2021-01-01"},
            {"key": "date_to", "value": "2022-02-02"},
            {"key": "category_id", "value": 3}
        ]
    }'
import requests
from pprint import pprint


# 结构化载荷。
payload = {
    'source': 'google_trends_explore',
    'query': 'adidas',
    'context': [
        {'key': 'date_from', 'value': '2021-01-01'},
        {'key': 'date_to', 'value': '2022-02-02'},
        {'key': 'category_id', 'value': 3},
    ],
}


# 获取响应。
response = requests.request(
    'POST',
    'https://realtime.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())

我们在示例中使用同步 Realtime 集成方法。如果您想使用 Proxy Endpoint 或异步 Push-Pull 集成,请参阅 集成方法 部分。

请求参数值

通用

抓取 Google Trends 结果的基础设置和自定义选项。

参数
描述
默认值

source

设置抓取器。

google_trends_explore

查询

要搜索的关键词或短语。

-

callback_url

回调端点的 URL。 更多信息

-

user_agent_type

设备类型和浏览器。完整列表可在 此处.

desktop

geo_location

结果应适配的地理位置。对于 Google Trends: Explore,我们接受 2 位 ISO 国家代码作为 geo_location 参数值。

-

- 必填参数

筛选

用于定制和细化搜索上下文的高级选项。

参数
描述
默认值

context:

search_type

用于设置搜索类型(Google Trends 界面上的选项之一)。可选值: web_search, image_search, google_shopping, youtube_search.

web_search

context:

date_from

下限日期边界。格式: YYYY-MM-DD。最早可能日期: 2004-01-01.

-

context:

date_to

上限日期边界。格式: YYYY-MM-DD。最早可能日期: 2004-01-01.

-

context:

category_id

类别 ID。请参阅 此文件 中的有效值列表。

-

Context 参数

所有 context 参数都应添加到 context 数组中,作为带有 对的对象,例如:

注意: 此服务始终返回结构化数据 - 因此无需在此 source 中使用 解析 参数。

输出示例

最后更新于

这有帮助吗?