httpx-socks
The httpx-socks package provides proxy transports for httpx client.
SOCKS4(a), SOCKS5(h), HTTP CONNECT proxy supported.
It uses python-socks for core proxy functionality.
Requirements
- Python >= 3.8
- httpx>=0.28.0,<0.29.0
- python-socks>=2.4.3,<3.0.0
- trio>=0.24 (optional)
- anyio>=3.3.4,<5.0.0 (optional)
Installation
only sync proxy support:
pip install httpx-socks
to include optional asyncio support (it requires async-timeout):
pip install httpx-socks[asyncio]
to include optional trio support:
pip install httpx-socks[trio]
Usage
sync transport
import httpx
from httpx_socks import SyncProxyTransport
def fetch(url):
transport = SyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
with httpx.Client(transport=transport) as client:
res = client.get(url)
return res.text
async transport (asyncio, trio)
import httpx
from httpx_socks import AsyncProxyTransport
async def fetch(url):
transport = AsyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
async with httpx.AsyncClient(transport=transport) as client:
res = await client.get(url)
return res.text
secure proxy connections (aka "HTTPS proxies", experimental feature, both sync and async support)
import ssl
import httpx
from httpx_socks import AsyncProxyTransport
async def fetch(url):
proxy_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS)
proxy_ssl.verify_mode = ssl.CERT_REQUIRED
proxy_ssl.load_verify_locations(...)
transport = AsyncProxyTransport.from_url('http://user:password@127.0.0.1:8080', proxy_ssl=proxy_ssl)
async with httpx.AsyncClient(transport=transport) as client:
res = await client.get(url)
return res.text
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
httpx_socks-0.12.0.tar.gz
(17.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpx_socks-0.12.0.tar.gz.
File metadata
- Download URL: httpx_socks-0.12.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d444ae0a00fda1a16f70ac15f14ad4cd77b83b8066273e0d272c73d5342c82
|
|
| MD5 |
23fc859febd59f528d93e51ca20c4430
|
|
| BLAKE2b-256 |
8cec07eb74cfd8297c0504d3aaaa49ea367097c4c282ade44067ccdd202e2ed4
|
File details
Details for the file httpx_socks-0.12.0-py3-none-any.whl.
File metadata
- Download URL: httpx_socks-0.12.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36f2cc7ef3443494984c7b3384b5182b71524fd6e6188103ff8cd0297527247a
|
|
| MD5 |
d0157b47025d61d5b4a6634449b786ab
|
|
| BLAKE2b-256 |
84560daa24dbae6223be7ec8d7ee01d5d5a0ae38e2884afd483f1c31be73c703
|