GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - quantumproxies/socks5-proxy-python: SOCKS5 proxies in Python with requests, httpx and aiohttp — and why socks5h beats socks5.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.md
README.md
 
 
socks5.py
socks5.py
 
 

Repository files navigation

SOCKS5 Proxy in Python — requests, httpx & aiohttp

Working SOCKS5 proxy setups for the three Python HTTP clients people actually use, plus the one detail that silently breaks privacy: local vs. remote DNS.

requests

pip install "requests[socks]"
import requests

proxy = "socks5h://USER:[email protected]:12000"
#             ^ socks5h = DNS resolved by the proxy, not your machine

r = requests.get("https://ipinfo.io/json",
                 proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.json())

socks5:// resolves hostnames locally — your DNS resolver sees every domain you scrape. socks5h:// pushes resolution through the exit node. Use socks5h unless you have a reason not to.

httpx

pip install "httpx[socks]"
import httpx

client = httpx.Client(proxy="socks5://USER:[email protected]:12000")
print(client.get("https://ipinfo.io/json").json())

aiohttp

pip install aiohttp aiohttp-socks
from aiohttp_socks import ProxyConnector
import aiohttp, asyncio

async def main():
    connector = ProxyConnector.from_url("socks5://USER:[email protected]:12000")
    async with aiohttp.ClientSession(connector=connector) as s:
        async with s.get("https://ipinfo.io/json") as r:
            print(await r.json())

asyncio.run(main())

When SOCKS5 over HTTP proxies

SOCKS5 is protocol-agnostic — it tunnels raw TCP. That covers non-HTTP traffic (custom protocols, some anti-bot WebSocket checks) and avoids proxy-side header rewriting entirely. Geo flags work the same as HTTP: USER-country-de, -session-x9-lifetime-10, etc.

Full demo across all three clients: socks5.py.

Endpoint used here: QuantumProxies SOCKS5 proxies — residential SOCKS5 on port 12000, 195+ countries, per-GB billing, credentials from app.quantumproxies.io.

About

SOCKS5 proxies in Python with requests, httpx and aiohttp — and why socks5h beats socks5.

quantumproxies.io/socks5-proxies

Topics

aiohttphttpxproxypythonrequestssocks5

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.