集成
任何支持 HTTP 或 SOCKS5 的客户端都可以配合 Shifter 网关使用。以下是大多数客户使用的工具的可直接复制粘贴的配置。
curl -x customer-USERNAME-country-us-sid-9f3a2b7c-ttl-600:PASSWORD@p.shifter.io:443 \ https://ipinfo.io/jsonhttps_proxy=customer-USERNAME-country-us-sid-9f3a2b7c-ttl-600:PASSWORD@p.shifter.io:443 \ wget -qO- https://ipinfo.io/jsonScrapy
Section titled “Scrapy”这个中间件会按请求轮换代理 URL,并允许爬虫通过 request.meta 覆盖国家参数:
DOWNLOADER_MIDDLEWARES = { "scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware": 110, "your_project.middlewares.ShifterProxyMiddleware": 100,}
# middlewares.pyimport os
class ShifterProxyMiddleware: def process_request(self, request, spider): username = os.environ["SHIFTER_USERNAME"] password = os.environ["SHIFTER_PASSWORD"] country = request.meta.get("shifter_country", "us") request.meta["proxy"] = ( f"http://{username}-country-{country}:{password}@p.shifter.io:443" )可以通过 request.meta["shifter_country"] = "de" 按请求覆盖设置。
Puppeteer
Section titled “Puppeteer”import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({ args: ['--proxy-server=http://p.shifter.io:443'],});const page = await browser.newPage();
await page.authenticate({ username: 'customer-USERNAME-country-us-sid-s1-ttl-600-sid-9f3a2b7c-ttl-600', password: 'PASSWORD',});
await page.goto('https://ipinfo.io/json');console.log(await page.content());await browser.close();Playwright
Section titled “Playwright”import { chromium } from 'playwright';
const browser = await chromium.launch({ proxy: { server: 'http://p.shifter.io:443', username: 'customer-USERNAME-country-us-sid-s1-ttl-600-sid-9f3a2b7c-ttl-600', password: 'PASSWORD', },});const page = await browser.newPage();await page.goto('https://ipinfo.io/json');SwitchyOmega
Section titled “SwitchyOmega”- 打开 Options → New Profile → Proxy Profile。
- 协议:
HTTP,服务器:p.shifter.io,端口:443。 - 用户名:
customer-USERNAME-country-us。密码:PASSWORD。 - 应用更改并切换到新配置文件。
Multilogin / GoLogin
Section titled “Multilogin / GoLogin”在浏览器配置文件设置中:
- 连接类型:HTTP Proxy
- 主机:
p.shifter.io - 端口:
443 - 用户名:
customer-USERNAME-country-us-sid-<profile-id>-ttl-1800 - 密码:
PASSWORD
使用配置文件 ID 作为会话 ID,这样每个受管浏览器在整个会话期间都能保持一致的 IP。