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@gate.zentislabs.com:7777"
proxies = {"http": proxy_url, "https": proxy_url}
# Each request gets a different IP
for i in range(5):
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
print(f"Request {i+1}: {r.json()['origin']}")
# With session-based sticky IP (same IP for 10 minutes)
sticky_proxy = "http://USER:PASS_session-abc123@gate.zentislabs.com:7777"
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@gate.zentislabs.com:7777');
async function fetchWithProxy() {
const { data } = await axios.get('https://httpbin.org/ip', {
httpsAgent: agent,
timeout: 10000,
});
console.log('IP:', data.origin);
}
// Rotate through 5 requests
for (let i = 0; i < 5; i++) {
await fetchWithProxy();
}Bash / cURL Setup
# Simple rotating proxy request
curl -x http://USER:PASS@gate.zentislabs.com:7777 https://httpbin.org/ip
# Loop with different IPs
for i in {1..5}; do
echo "Request $i:"
curl -s -x http://USER:PASS@gate.zentislabs.com:7777 https://httpbin.org/ip
echo ""
done
# With geo-targeting (US only)
curl -x http://USER:PASS_country-us@gate.zentislabs.com:7777 https://httpbin.org/ip Pro tip: Use session IDs for sticky sessions when scraping multi-page flows (login navigate scrape). Add _session-XXXX to your username.
Geo-Targeting
ZentisLabs supports country, state, and city-level targeting. Append targeting params to your username:
Country: USER_country-us
State: USER_country-us_state-california
City: USER_country-de_city-berlinError Handling
Always implement retries with exponential backoff. Proxy connections can occasionally timeout this is normal for residential IPs.
import time
import requests
from 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")