Skip to content
登录 注册

地理定位

地理定位通过在用户名中添加标志按请求进行配置。无需更改控制面板,无需单独的端点,每个请求都通过同一个网关。

标志以短划线附加到用户名中:

customer-USERNAME-country-<code>-region-<name>-city-<name>-asn-<number>

值均为小写。地区和城市名称中的空格用下划线表示。国家代码为 ISO 3166-1 alpha-2 格式。

标志示例
countryISO 国家代码country-us, country-gb, country-de
region小写地区/州标识region-california, region-new_south_wales
city小写城市标识city-new_york, city-los_angeles
asnASN 编号asn-7922 (Comcast), asn-701 (Verizon)
stricttruestrict-true(参见回退行为

可按任意顺序组合标志:

customer-USERNAME-country-us-region-california-city-los_angeles
customer-USERNAME-country-gb-asn-2856
customer-USERNAME-city-berlin
Terminal window
curl -x customer-USERNAME-country-de-sid-9f3a2b7c-ttl-600:PASSWORD@p.shifter.io:443 \
https://ipinfo.io/json

默认情况下,如果在请求时没有 IP 与你的完整过滤条件匹配(例如,某个冷门城市的 IP 池暂时为空),网关会回退到更广泛的池,以便请求仍能完成。

添加 strict-true 可选择退出回退机制,此时将收到 HTTP 502 而非回退结果。当精确的地理匹配比请求成功更重要时,请使用严格匹配:

Terminal window
curl -x customer-USERNAME-country-us-city-new_york-strict-true-sid-9f3a2b7c-ttl-600:PASSWORD@p.shifter.io:443 \
https://ipinfo.io/json

省略所有标志即可从完整的全球池中获取:

USERNAME

每个请求仍会轮换到不同的 IP,只是没有地理限制。

  • 会话,在多个请求间保持目标 IP。
  • 集成,将地理标志接入 Scrapy、Puppeteer、Playwright。