Skip to content
登录 注册

位置

对于大多数 SERP 请求,使用自由格式的 location= 字符串就足够了。当您需要根据 Google 自身的位置分类体系进行标准化的城市级定位匹配时,请使用 Locations API 将地点字符串解析为 uule 值。

将位置作为字符串传递。Shifter 会实时将其解析为最匹配的地理位置。

Terminal window
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=pizza&location=Chicago%2C+Illinois"

这适用于 95% 的使用场景。缺点是:含糊的字符串(SpringfieldLondon)可能会匹配到与您预期不同的城市。

使用 Locations API 进行标准化地理定位

Section titled “使用 Locations API 进行标准化地理定位”

要确保指定特定城市,请先解析该位置:

Terminal window
curl "https://serp.shifter.io/v1?engine=locations&api_key=YOUR_API_KEY&q=Chicago"

响应会列出所有匹配的位置,包含标准名称、country_codetarget_type(City、State、Country)以及 google_id。选择您需要的位置,并在 location= 中使用其标准名称:

Terminal window
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=pizza&location=Chicago%2CIllinois%2CUnited+States"

组合使用 gl(国家)和 hl(语言)以获得格式正确的结果:

glhl获得的结果
usen英文的美国结果(默认)
dede德文的德国结果
jpja日文的日本结果
brpt葡萄牙文的巴西结果
Terminal window
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=news&gl=de&hl=de"

移动端和桌面端 SERP 存在显著差异(不同的功能、不同的排名)。请明确选择:

Terminal window
curl "https://serp.shifter.io/v1?engine=google&api_key=YOUR_API_KEY&q=laptop&device=mobile"

可选值:desktop(默认)、mobiletablet

Yandex 通过 lr 使用其自有的位置 ID:

lr城市
1莫斯科
2圣彼得堡
11316新西伯利亚
54叶卡捷琳堡

完整列表可通过 engine=yandex_locations 获取。