How to use a proxy in Python Requests (HTTP/HTTPS & Session pooling)
Updated:
Python's requests library accepts authenticated VinaProxy proxies via a proxies dictionary mapping both 'http' and 'https' schemes to http://user:pass@ip:port. Attaching that dictionary to a persistent requests.Session() reuses underlying TCP sockets for fast, low-overhead web scraping.
proxies = {'http': 'http://user:pass@ip:port', 'https': 'http://user:pass@ip:port'}- 1 IP₫40,000
- 5+ IPs₫35,000
- 10+ IPs₫25,000
- 20+ IPs₫25,000
- 50+ IPs₫25,000
- 100+ IPs₫25,000
- 200+ IPs₫25,000
- 500+ IPs₫25,000
- 1000+ IPs₫22,000
- 2000+ IPs₫20,000
- 1 IP₫40,000
- 5+ IPs₫35,000
- 10+ IPs₫25,000
- 20+ IPs₫25,000
- 50+ IPs₫25,000
- 100+ IPs₫25,000
- 200+ IPs₫25,000
- 500+ IPs₫25,000
- 1000+ IPs₫22,000
- 2000+ IPs₫20,000
Formatting the proxies dictionary & reusing Sessions
Calling requests.get() on every URL creates a brand-new TCP connection and TLS handshake each time. Binding your proxy to session = requests.Session() keeps the proxy tunnel open across consecutive requests.
| Requests Parameter | Recommended Syntax | Technical Purpose |
|---|---|---|
'http' key | 'http://user:pass@ip:port' | Routes plain HTTP requests through the proxy |
'https' key | 'http://user:pass@ip:port' | Uses http:// scheme so urllib3 issues an HTTP CONNECT tunnel for TLS |
timeout tuple | timeout=(5, 15) | 5s connect timeout and 15s read timeout prevents hung worker threads |
| Pool rotation | itertools.cycle(proxy_list) | Cycles evenly across your dedicated static IP pool |
Avoiding common urllib3 & ProxyError pitfalls
- Always use
http://(nothttps://) as the proxy URL scheme for both'http'and'https'dictionary keys unless your proxy port explicitly requires TLS-over-TLS - URL-encode special characters in passwords using
urllib.parse.quote(password, safe='') - A
407 Proxy Authentication Requirederror means the username or password in your URL string did not match your dashboard credentials - Works identically with
httpx.Client(proxy='http://user:pass@ip:port')andaiohttpsession.get(url, proxy=...)
Step by step
- 1
Convert ip:port:user:pass to URL syntax
Use our Proxy Format Converter to transform your VinaProxy list into
http://user:pass@ip:portstrings. - 2
Define the proxies dictionary
Set
proxies = {'http': 'http://user:pass@ip:port', 'https': 'http://user:pass@ip:port'}in your Python script. - 3
Attach to a requests.Session() instance
Initialize
s = requests.Session()and calls.proxies.update(proxies)for persistentKeep-Alivepooling. - 4
Verify exit IP with a test request
Run
print(s.get('https://vinaproxy.com/api/my-ip', timeout=10).json())to confirm the active proxy IP.
Frequently asked questions
Why does the 'https' key use 'http://user:pass@ip:port'?
The http:// prefix tells urllib3 how to connect to the proxy server itself (using standard HTTP CONNECT), while your end-to-end traffic to the target https:// website remains fully TLS-encrypted.
How do I rotate 25 static proxies across requests in Python?
Load your 25 proxy URLs into pool = itertools.cycle(PROXIES) and pass proxies={'http': p, 'https': p} per request with polite per-IP rate limiting.
Does VinaProxy meter bandwidth on Python scraping scripts?
No. All Dedicated IPv4 and Static ISP plans include unlimited monthly traffic.
Build an unmetered Python scraping pool
Instant Dedicated IPv4 and Static ISP proxies across 7 countries.
Buy Python Proxies