Python requests & httpx: Rotating and Sticky Residential Proxies
In Python `requests` and `httpx`, residential proxy rotation works without maintaining IP lists by sending requests through a single backconnect gateway (`gw.resi.fast:8080`). Omit the session flag for a fresh exit IP on every request, or pass `_sess-<id>_ttl-15m` to hold the same IP across a multi-step session.
1. Async concurrency with httpx
For high-throughput scraping in Python, `httpx.AsyncClient` with bounded concurrency (`asyncio.Semaphore`) and explicit connect/read timeouts avoids hanging sockets.
import asyncio, httpx
PROXY = "http://rf_yourkey__pool-resi_cr-us:[email protected]:8080"
async def fetch_all(urls: list[str]):
sem = asyncio.Semaphore(20)
async with httpx.AsyncClient(proxy=PROXY, timeout=httpx.Timeout(15.0)) as client:
async def one(u: str):
async with sem:
r = await client.get(u)
return u, r.status_code, len(r.content)
return await asyncio.gather(*(one(u) for u in urls))
print(asyncio.run(fetch_all(["https://ipinfo.io/json"] * 3)))2. Retrying 502/503 cleanly
Residential exit nodes are real consumer devices that can occasionally go offline mid-request. Retry `502`, `503`, and `ConnectTimeout` up to 3 times with short jitter (200-500 ms). On resi.fast, failed 502/503 gateway dials incur $0 traffic cost.
FAQ
Do I need to install a separate SDK for Python?
No. Standard `requests`, `httpx`, `aiohttp`, `urllib3`, and `scrapy` work out of the box with standard proxy URLs.