How to rotate IPs and pick a country with tunneling
Sometimes you do not want an extraction API. You already have a scraper, a test suite or a script, and you just need its requests to leave from a different IP each time, or from a specific country. The scrape.land tunnel does that for any HTTP client, with your API key as the only credential and no SDK to install.
The one-line version
Point your client's tunnel setting at gateway.scrape.land:8080 and put your key in the username. With curl that is the -x flag:
curl -x "http://YOUR_KEY-country-de:@gateway.scrape.land:8080" https://api.ipify.org?format=json{"ip":"203.0.113.24"}Run it again and you get a different address:
{"ip":"203.0.113.87"}Every request gets a new exit IP. The -country-de suffix on the key asks for an exit in Germany; use any two-letter ISO country code, or leave the suffix off to exit anywhere. The password is empty, which is why the key is followed by a bare :.
From Python
The requests library takes the same URL. Nothing else in your code changes: headers, cookies, sessions and retries all work as before.
import requests
KEY = "YOUR_KEY"
tunnel = f"http://{KEY}-country-de:@gateway.scrape.land:8080"
proxies = {"http": tunnel, "https": tunnel}
for _ in range(3):
r = requests.get("https://api.ipify.org?format=json", proxies=proxies, timeout=30)
print(r.json()["ip"])The output is three different addresses, all in Germany. Replace the ipify URL with the page you actually want, and the rest of your scraper stays the same.
Options you can add to the key
Options are -name-value pairs appended to the key, in any order:
-country-us: pick the exit country.-session-abc123: keep the same exit IP for every request that uses this session name. Use it when a site ties a login or a cart to your IP. Pick a new name to get a new IP.-protocol-socks5: choose the exit's protocol (http,httpsorsocks5). Leave it out to use any.
For example, a German exit that stays fixed for a whole login flow:
curl -x "http://YOUR_KEY-country-de-session-checkout7:@gateway.scrape.land:8080" https://example.com/accountHTTPS targets
HTTPS sites work as normal. Your client opens an encrypted connection to the target through the tunnel, so the page content stays between you and the site. Keep the http:// scheme in the tunnel URL even when the target is HTTPS: that scheme describes how your client talks to the gateway, not the site.
If your network blocks port 8080 (common on corporate, university and hotel networks), the gateway also answers on port 443 with identical behaviour and billing: use gateway.scrape.land:443.
Other tools
Anything that supports an HTTP tunnel setting with a username works the same way: Node's https-proxy-agent, Go's http.Transport, Scrapy, Playwright and Puppeteer (as a launch option), or an environment variable for command-line tools:
export HTTPS_PROXY="http://YOUR_KEY-country-us:@gateway.scrape.land:8080"
curl https://api.ipify.org?format=jsonBrowsers cannot set a different tunnel per request from inside a web page, so call the tunnel from a backend or a script, not from front-end JavaScript.
Tunnel or extraction API?
Use the tunnel when you already have code that fetches and parses pages and you only need rotating exits and country control. Use /v1/fetch or /v1/extract when you would rather send a URL and get back HTML, Markdown or the exact fields you want as JSON, with rendering available for JavaScript pages. Both use the same key and the same request allowance.
What it costs
Each delivered request is 1 request unit, and you only pay for responses that land: blocks and retries are free. The Free plan includes 1,000 requests a month with no card; paid plans go down to $0.139 per 1,000 requests on Business. See pricing.
Next steps
The full list of key options and the header equivalents is in the docs, along with a tunnel URL builder. Create a free account to get a key and run the curl command above.