Free · no signup
Rotator Generator
Produce working rotation code with retry and timeout handling already wired in — paste your proxies and copy the result.
Configure
Rotation
import random
import requests
PROXIES = [
'http://user:pass@host:port',
]
TARGET = 'https://httpbin.org/ip'
RETRIES = 3
TIMEOUT = 15
_index = 0
def next_proxy():
"""Pick a random proxy for each request."""
return random.choice(PROXIES)
def fetch(url=TARGET):
last_error = None
for attempt in range(RETRIES):
proxy = next_proxy()
try:
response = requests.get(
url,
proxies={"http": proxy, "https": proxy},
timeout=TIMEOUT,
)
response.raise_for_status()
return response
except requests.RequestException as error:
last_error = error
print(f"attempt {attempt + 1}/{RETRIES} failed via {proxy}: {error}")
raise RuntimeError(f"all {RETRIES} attempts failed") from last_error
if __name__ == "__main__":
result = fetch()
print(result.status_code, len(result.text), "bytes")
Generated locally
The snippet is assembled in your browser, so the credentials you paste are never sent to us. Review any generated code before running it, and keep credentials out of version control — load them from environment variables in anything you deploy.