登录

API 用法

Crawling API 请求中添加 &scraper=google-serp。在 url 参数中对目标 URL 进行 URL 编码。

curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
  --data-urlencode 'url=https://www.google.com/search?q=samsung+social+accounts' \
  --data-urlencode 'scraper=google-serp' -G
from crawlbase import CrawlingAPI

api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
    'https://www.google.com/search?q=samsung+social+accounts',
    {'scraper': 'google-serp'}
)

import json
data = json.loads(res['body'])
const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });

const res = await api.get(
  'https://www.google.com/search?q=samsung+social+accounts',
  { scraper: 'google-serp' }
);
const data = JSON.parse(res.body);
require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')

res = api.get('https://www.google.com/search?q=samsung+social+accounts', scraper: 'google-serp')
data = JSON.parse(res.body)

示例输入 URL

传入 url 参数的 URL(为方便阅读已 URL 解码):

https://www.google.com/search?q=samsung+social+accounts

响应结构

JSON 响应体。当源页面缺少对应值时,字段类型可能为 null

query
string
搜索查询。
results
array
自然搜索结果。
results[].title
string
结果标题。
results[].url
string
结果目标 URL。
results[].snippet
string
标题下方显示的描述文字。
results[].sitelinks
array
主结果下的可选站内链接。
ads
array
赞助广告,结构与 results[] 相同。
related_searches
array<string>
「Searches related to」相关搜索建议。
people_also_ask
array
PAA 模块,包含问答对。
knowledge_panel
object | null
存在时返回的知识面板区块。

示例响应

{
  "query": "samsung social accounts",
  "results": [
    {
      "title": "Samsung Mobile (@SamsungMobile) / X",
      "url": "https://x.com/SamsungMobile",
      "snippet": "The official Samsung Mobile X account…"
    }
  ],
  "related_searches": ["samsung instagram", "samsung official tiktok"],
  "people_also_ask": [
    {
      "question": "Does Samsung have a TikTok?",
      "answer": "Yes, Samsung is on TikTok at @samsung."
    }
  ]
}