crawlbase文档
登录

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' -G
from 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

trends
array
页面上的热搜,按排名顺序排列。
trends[].position
integer
该热搜在页面中的排名(从 1 开始)。
trends[].title
string
Google Trends 页面上显示的热搜查询词。
trends[].searchVolume
string
热搜的缩写搜索量(例如 20K+1M+)。
trends[].searchVolumeText
string
本地化的可读搜索量标签(例如 20K+ searches)。
trends[].increasePercentage
string
页面上显示的搜索热度近期增长幅度。
trends[].started
string
热搜开始上升的时间,以相对时间字符串表示(例如 6 hours ago)。
trends[].status
string
Google 显示的热搜状态(通常为 ActiveLasted)。
trends[].trendBreakdown
array<string>
Google 归入该热搜下的相关子查询。
trends[].trendBreakdownMoreCount
integer
trendBreakdown 中列出的子查询外,额外的子查询数量。
trendsCount
integer
trends 中返回的热搜总数。
filters
object
从 Google Trends URL 解码得到的、页面所反映的筛选状态。
filters.geo
string
热搜所限定的解析后地理区域标签(国家或子区域)。
filters.timeRange
string
页面所筛选的时间范围标签(例如 Past 7 days)。
filters.category
string
类别筛选标签(例如 All categories)。
filters.trendType
string
热搜类型筛选标签(例如 All trends)。
filters.sortBy
string
排序方式标签(例如 By relevanceBy search volume)。
filters.updatedAtText
string
本地化标签,显示 Google 上次更新页面的时间。
pagination
object
当前请求的分页状态。
pagination.currentPage
integer
当前响应的页码(从 1 开始)。
pagination.itemsPerPage
integer
Google 每页返回的热搜数量。
pagination.totalItems
integer
当前筛选条件下所有分页可获得的热搜总数。
pagination.hasNextPage
boolean
当后续页面还有更多热搜时为 true
pagination.hasPreviousPage
boolean
当存在上一页时为 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
  }
}