
1. Install SOCKS support
pip install requests[socks]2. HTTP proxy
import requests
proxy = "203.0.113.10:8080"
response = requests.get(
"https://api.ipify.org",
proxies={"http": f"http://{proxy}", "https": f"http://{proxy}"},
timeout=8,
)
print(response.text)3. SOCKS5 proxy with remote DNS
import requests
proxy = "203.0.113.10:1080"
response = requests.get(
"https://api.ipify.org",
proxies={"http": f"socks5h://{proxy}", "https": f"socks5h://{proxy}"},
timeout=8,
)Notes that save time
The h in socks5h matters: it tells requests to resolve the hostname through the proxy instead of locally, which keeps your resolver out of the picture. Always pass a timeout — requests waits forever by default, and a dead free proxy will hang the call. Wrap the request in try/except and move to the next entry rather than retrying the same one.
Related guides
Public snapshot boundary
Free public proxies are shared and operated by unknown parties. Never send passwords, tokens or personal data through them. Follow the GitHub Acceptable Use Policies: no spam, no attacks, no bypassing access controls, no scraping against site policies.
Free public proxies are shared and operated by unknown parties. Never send passwords, tokens or personal data through them. Follow the GitHub Acceptable Use Policies: no spam, no attacks, no bypassing access controls, no scraping against site policies.