Setting up rotating proxies is essential for web scraping, data collection, and automation at scale. In this guide, we'll walk through complete implementations in Python, Node.js, and Bash - all using ZentisLabs's rotating residential proxy gateway.
Prerequisites
- A ZentisLabs account with an active residential proxy plan
- Your API credentials (username + password) from the dashboard
- Python 3.8+, Node.js 18+, or Bash with curl installed
Python Setup
Using the requests library with ZentisLabs's rotating gateway:
import requests
proxy_url = "http://USER:PASS@basic.resi.zentislabs.com:12321"proxies = {"http": proxy_url, "https": proxy_url}
# Each request gets a different IPfor i in range(5): r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10) print(f"Request {i+1}: {r.json()['origin']}")
# Sticky IP (same IP for 10 minutes): paste a sticky line exactly as generated# in the dashboard or API. Generated sticky lines are pinned to one gateway node.host, port, user, password = "NODE_IP:12321:USER:PASS_country-us_session-abc123_lifetime-10m".split(":")sticky_proxy = f"http://{user}:{password}@{host}:{port}"session = requests.Session()session.proxies = {"http": sticky_proxy, "https": sticky_proxy}
for i in range(3): r = session.get("https://httpbin.org/ip", timeout=10) print(f"Sticky {i+1}: {r.json()['origin']}") # Same IP each timeNode.js Setup
const axios = require('axios');const { HttpsProxyAgent } = require('https-proxy-agent');
const agent = new HttpsProxyAgent('http://USER:PASS@basic.resi.zentislabs.com:12321');
async function fetchWithProxy() { const { data } = await axios.get('https://httpbin.org/ip', { httpsAgent: agent, proxy: false, timeout: 10000, }); console.log('IP:', data.origin);}
// Rotate through 5 requests(async () => { for (let i = 0; i < 5; i++) { await fetchWithProxy(); }})();Bash / cURL Setup
# Simple rotating proxy requestcurl -x http://USER:PASS@basic.resi.zentislabs.com:12321 https://httpbin.org/ip
# Loop with different IPsfor i in {1..5}; do echo "Request $i:" curl -s -x http://USER:PASS@basic.resi.zentislabs.com:12321 https://httpbin.org/ip echo ""done
# With geo-targeting (US only)curl -x http://USER:PASS_country-us@basic.resi.zentislabs.com:12321 https://httpbin.org/ipPro tip: Use sticky sessions when scraping multi-page flows (login → navigate → scrape). Generate sticky lines in the dashboard or API and use them exactly as generated: each carries its own _session-XXXX ID and is pinned to one gateway node, so your IP holds for the whole flow.
Geo-Targeting
ZentisLabs supports country, state, and city-level targeting. On the Basic and Light plans, append targeting params to your password (a city always follows its state):
Country: PASS_country-usState: PASS_country-us_state-californiaCity: PASS_country-de_state-berlin-city-berlinError Handling
Always implement retries with exponential backoff. Proxy connections can occasionally timeout - this is normal for residential IPs.
import timeimport requestsfrom requests.exceptions import ProxyError, Timeout
def fetch_with_retry(url, proxies, max_retries=3): for attempt in range(max_retries): try: return requests.get(url, proxies=proxies, timeout=15) except (ProxyError, Timeout) as e: wait = 2 ** attempt print(f"Retry {attempt+1} in {wait}s: {e}") time.sleep(wait) raise Exception("Max retries exceeded")