地区、语言与设备
同一个关键词,Google 会按国家、语言、城市和设备给出不同结果。用四个参数决定你拿到哪个版本。
gl · hl · location · device
| 名称 | 作用 |
|---|---|
gl | 结果所属国家,两位代码:us、gb、de、jp…… |
hl | 页面语言:en、de、ja、pt-BR……建议和同一市场的 gl 一起用。 |
location | 模拟从某个城市或地区搜索,例如 "Munich,Bavaria,Germany"。仅对手机端结果生效;名称用 GET /google/locations 查询。 |
device | mobile(默认)或 pc。两种页面不同,有些板块只出现在其中一种上。 |
gl 和 hl 适用于大多数 Google 接口;device 和 location 用于 Google 网页搜索。每个接口的参数表都列出了它支持的参数。这些参数都不影响价格。
BASH
curl -X POST https://api.serpbase.dev/google/search \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "coffee shops", "gl": "de", "hl": "de", "location": "Munich,Bavaria,Germany"}'搜索地点
查询 Google 搜索 location 参数可用的取值。结果中的 canonical_name 可直接作为 /google/search 的 location 传入。该请求不消耗额度。
GET
0 点
/google/locations?q=munich&country_code=de&limit=5q(必填)按地点名或标准名匹配,不区分大小写;country_code 按 ISO 3166-1 两位国家代码筛选;limit 取 1-100(默认 20)。完全匹配的名称排在前面,其次是范围大的地点。同名地点很多(如法国巴黎和美国德州的 Paris),请用 country_code 筛选出需要的那个。请在 X-API-Key 请求头中传入密钥。
BASH
curl "https://api.serpbase.dev/google/locations?q=munich&country_code=de&limit=2" \
-H "X-API-Key: your_api_key"
curl -X POST https://api.serpbase.dev/google/search \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"q":"crossfit software","gl":"de","hl":"de","device":"mobile","location":"Munich,Bavaria,Germany"}'JSON
{
"status": 0,
"locations": [
{
"canonical_name": "Munich,Bavaria,Germany",
"name": "Munich",
"country_code": "DE",
"target_type": "City"
},
{
"canonical_name": "Taufkirchen,Munich,Bavaria,Germany",
"name": "Taufkirchen",
"country_code": "DE",
"target_type": "City"
}
]
}| 国家(location 取值) | gl | 城市示例 |
|---|---|---|
| United States | us | New York,New York,United States |
| United Kingdom | gb | London,England,United Kingdom |
| Germany | de | Munich,Bavaria,Germany |
| Austria | at | Vienna,Vienna,Austria |
| Switzerland | ch | Zurich,Zurich,Switzerland |
| France | fr | Paris,Ile-de-France,France |
| Italy | it | Milan,Lombardy,Italy |
| Spain | es | Madrid,Community of Madrid,Spain |
| Poland | pl | Warsaw,Masovian Voivodeship,Poland |
| Canada | ca | Toronto,Ontario,Canada |
| Australia | au | Sydney,New South Wales,Australia |
| Japan | jp | Tokyo,Tokyo,Japan |
| Indonesia | id | Jakarta,Jakarta,Indonesia |
| Philippines | ph | Manila,Metro Manila,Philippines |
| Brazil | br | Sao Paulo,State of Sao Paulo,Brazil |
| Mexico | mx | Mexico City,Mexico City,Mexico |
每个账户每分钟最多查询 60 次。不在列表中的 location 会被忽略而不是报错:搜索照常进行,只是不带地点。location 仅对手机端搜索生效(device 为 mobile,即默认值)。