requests
import requests
proxy = "http://USERNAME:PASSWORD@HOST:PORT"
r = requests.get("https://api.ipify.org?format=json",
proxies={"http": proxy, "https": proxy}, timeout=20)
print(r.json())For SOCKS5, install requests[socks] and use socks5h://USERNAME:PASSWORD@HOST:PORT so DNS goes through the proxy too. See our Python requests proxies guide for more.
Rotate through a static list
Proxy Seller IPv4, IPv6 and ISP proxies are static, so rotate in your code:
import itertools, requests
proxies = [line.strip() for line in open("proxies.txt") if line.strip()] # host:port:user:pass
def to_url(p):
host, port, user, pw = p.split(":")
return f"http://{user}:{pw}@{host}:{port}"
pool = itertools.cycle(map(to_url, proxies))
for url in ["https://example.com/page1", "https://example.com/page2"]:
p = next(pool)
try:
r = requests.get(url, proxies={"http": p, "https": p}, timeout=20)
print(url, r.status_code)
except requests.RequestException as e:
print(url, "failed:", e)Keep threads per IP low; static proxies allow 100 connections per IP by default under fair use, and far fewer is better for block rates.

httpx and async
import asyncio, httpx
async def main():
async with httpx.AsyncClient(proxy="http://USERNAME:PASSWORD@HOST:PORT", timeout=20) as client:
r = await client.get("https://api.ipify.org")
print(r.text)
asyncio.run(main())Coupon tip: Proxy Seller has no free trial, so the cheapest test is a one-week rental of a few IPs or 1 GB of residential traffic with code MONKEYS. Our our complete Proxy Seller guide explains which product fits which job.
Residential sessions
For residential, set rotation per list in the dashboard (per request, timed, or sticky up to 24 hours), then use the credentials for that list. Make one list per behaviour you need. See rotation and sticky sessions.
Residential tip: Rayobyte is worth testing when you need precise targeting: its residential proxies can be pinned to a country, state, city, ZIP code or ASN, with sticky sessions from 1 to 120 minutes. More in using Rayobyte with Python.
Scrapy
Set request.meta["proxy"] in a downloader middleware, picking from your list, or use a rotating proxy middleware package. Our Scrapy proxies guide has a full example.
Handle errors
- 407: credentials or allowlist (see troubleshooting).
- 429 from the proxy: too many connections on one IP.
- Timeouts: retry with the next proxy and back off.
Proxy tip: If you're building a shortlist, add Geonode to it. It offers per-GB residential traffic that doesn't expire, unlimited residential plans, static ISP and rotating datacenter proxies, and scraping APIs. We look at where it fits in our Geonode proxies guide.
Retrying with the next proxy
import itertools, time, requests
def fetch(url, pool, tries=3):
for attempt in range(tries):
p = next(pool)
try:
r = requests.get(url, proxies={"http": p, "https": p}, timeout=20)
if r.status_code == 200:
return r
except requests.RequestException:
pass
time.sleep(2 ** attempt)
return NoneBack off between attempts, and if one proxy keeps failing, drop it from the pool and check it with Proxy Seller's free tools.
Before you buy, read our buy proxies guide for fair prices by type, check proxy coupons for current deals, and see the best proxies in 2026 for the wider market. For browser automation in depth, see our Puppeteer proxies guide.
Key takeaways
- Use
http://user:pass@host:portorsocks5h://URLs. - Rotate static lists in code; set residential rotation per list in the dashboard.
- Keep concurrency per IP low and retry on the next proxy.
Budget tip: If you want a cheap proxy to try this with, Webshare has a free plan with 10 datacenter proxies and 1 GB of bandwidth a month, no card required. Paid lists let you pick proxy count, bandwidth and location. See using Webshare with Python.
FAQ
Do Proxy Seller proxies work with Python requests?
Yes, with HTTP or SOCKS5 proxy URLs.
How do I use SOCKS5 with Python requests?
Install requests[socks] and use a socks5h://user:pass@host:port proxy URL.
Sources and further reading
Independent references that back up the points above, from standards bodies, governments, universities and non-profits. They open in a new tab.
- RFC 8200: Internet Protocol, Version 6 (IPv6) (IETF / RFC Editor): The current IPv6 specification, the address format behind IPv6 proxies.
- RFC 1928: SOCKS Protocol Version 5 (IETF / RFC Editor): The original specification of SOCKS5, including UDP support and authentication negotiation.
- Downloader Middleware (Scrapy documentation): Scrapy's documentation for the middleware where proxy rotation lives.
- 407 Proxy Authentication Required (MDN Web Docs (Mozilla)): The status code a proxy returns when credentials are missing or wrong.
- RFC 1929: Username/Password Authentication for SOCKS V5 (IETF / RFC Editor): How SOCKS5 proxies check a username and password.
Editorial note: Proxy providers change their pools, features and prices often, so treat any figures here as typical ranges at the time of writing and confirm current terms with the provider before you buy.