位置
对于大多数 SERP 请求,使用自由格式的 location= 字符串就足够了。当您需要根据 Google 自身的位置分类体系进行标准化的城市级定位匹配时,请使用 Locations API 将地点字符串解析为 uule 值。
自由格式位置(简单)
Section titled “自由格式位置(简单)”将位置作为字符串传递。Shifter 会实时将其解析为最匹配的地理位置。
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=pizza&location=Chicago%2C+Illinois"这适用于 95% 的使用场景。缺点是:含糊的字符串(Springfield、London)可能会匹配到与您预期不同的城市。
使用 Locations API 进行标准化地理定位
Section titled “使用 Locations API 进行标准化地理定位”要确保指定特定城市,请先解析该位置:
curl "https://serp.shifter.io/v1?engine=locations&api_key=YOUR_API_KEY&q=Chicago"响应会列出所有匹配的位置,包含标准名称、country_code、target_type(City、State、Country)以及 google_id。选择您需要的位置,并在 location= 中使用其标准名称:
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=pizza&location=Chicago%2CIllinois%2CUnited+States"国家与语言组合
Section titled “国家与语言组合”组合使用 gl(国家)和 hl(语言)以获得格式正确的结果:
gl | hl | 获得的结果 |
|---|---|---|
us | en | 英文的美国结果(默认) |
de | de | 德文的德国结果 |
jp | ja | 日文的日本结果 |
br | pt | 葡萄牙文的巴西结果 |
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=news&gl=de&hl=de"移动端和桌面端 SERP 存在显著差异(不同的功能、不同的排名)。请明确选择:
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=laptop&device=mobile"可选值:desktop(默认)、mobile、tablet。
Yandex 位置
Section titled “Yandex 位置”Yandex 通过 lr 使用其自有的位置 ID:
lr | 城市 |
|---|---|
| 1 | 莫斯科 |
| 2 | 圣彼得堡 |
| 11316 | 新西伯利亚 |
| 54 | 叶卡捷琳堡 |
完整列表可通过 engine=yandex_locations 获取。
- Google,引擎列表。
- REST API → SERP Locations,完整的 Google 地理参数参考。