Proxy (HTTP, SOCKS) transports for httpx
Project description
httpx-socks
The httpx-socks
package provides proxy transports for httpx client.
SOCKS4(a), SOCKS5, HTTP (tunneling) proxy supported.
It uses python-socks for core proxy functionality.
Requirements
- Python >= 3.6
- httpx >= 0.13.3
- python-socks[asyncio,trio,curio] >= 1.1.0
Installation
pip install httpx-socks
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, curio)
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
Project details
Release history Release notifications | RSS feed
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.3.0.tar.gz
(7.7 kB
view hashes)
Built Distribution
Close
Hashes for httpx_socks-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d48c00a07e391e1daf3c8963fb823a0a5ec1ce5db5af534aacff9b4350b454e |
|
MD5 | b04f9aa3faafbfcfea30529ba968375b |
|
BLAKE2b-256 | 23e237d915640b3b5b49f03970b21542d5371810a4889b47d89220a27632c324 |