Google Trends
将 Google Trends 的“Trending now”页面解析为结构化的热搜数组,包含搜索量指标、趋势细分、筛选条件和分页信息。
API 用法
在 Crawling API 请求中添加 &scraper=google-trends。在 url 参数中传入经过 URL 编码的目标 URL。geo、时间范围、类别等筛选条件作为查询字符串参数附加在 Google Trends URL 本身。
curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
--data-urlencode 'url=https://trends.google.com/trending?geo=AE-DU' \
--data-urlencode 'scraper=google-trends' -Gfrom crawlbase import CrawlingAPI
api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
'https://trends.google.com/trending?geo=AE-DU',
{'scraper': 'google-trends'}
)
import json
data = json.loads(res['body'])const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });
const res = await api.get(
'https://trends.google.com/trending?geo=AE-DU',
{ scraper: 'google-trends' }
);
const data = JSON.parse(res.body);require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')
res = api.get('https://trends.google.com/trending?geo=AE-DU', scraper: 'google-trends')
data = JSON.parse(res.body)示例输入 URL
传入 url 参数的 URL(为方便阅读已 URL 解码):
https://trends.google.com/trending?geo=AE-DU响应结构
JSON 响应体。当源页面缺少对应值时,字段类型可能为 null。
页面上的热搜,按排名顺序排列。
该热搜在页面中的排名(从 1 开始)。
Google Trends 页面上显示的热搜查询词。
热搜的缩写搜索量(例如
20K+、1M+)。本地化的可读搜索量标签(例如
20K+ searches)。页面上显示的搜索热度近期增长幅度。
热搜开始上升的时间,以相对时间字符串表示(例如
6 hours ago)。Google 显示的热搜状态(通常为
Active 或 Lasted)。Google 归入该热搜下的相关子查询。
除
trendBreakdown 中列出的子查询外,额外的子查询数量。trends 中返回的热搜总数。从 Google Trends URL 解码得到的、页面所反映的筛选状态。
热搜所限定的解析后地理区域标签(国家或子区域)。
页面所筛选的时间范围标签(例如
Past 7 days)。类别筛选标签(例如
All categories)。热搜类型筛选标签(例如
All trends)。排序方式标签(例如
By relevance、By search volume)。本地化标签,显示 Google 上次更新页面的时间。
当前请求的分页状态。
当前响应的页码(从 1 开始)。
Google 每页返回的热搜数量。
当前筛选条件下所有分页可获得的热搜总数。
当后续页面还有更多热搜时为
true。当存在上一页时为
true。响应示例
{
"trends": [
{
"position": 1,
"title": "al maktoum international airport (dwc)",
"searchVolume": "20K+",
"searchVolumeText": "20K+ searches",
"increasePercentage": "600%",
"started": "6 hours ago",
"status": "Active",
"trendBreakdown": ["dubai international airport"],
"trendBreakdownMoreCount": 0
}
],
"trendsCount": 5,
"filters": {
"geo": "Dubai",
"timeRange": "Past 7 days",
"category": "All categories",
"trendType": "All trends",
"sortBy": "By relevance",
"updatedAtText": "Updated Jun 2, 2:56 PM"
},
"pagination": {
"currentPage": 1,
"itemsPerPage": 25,
"totalItems": 25,
"hasNextPage": false,
"hasPreviousPage": false
}
}