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.15.4
- python-socks >= 1.1.0
- async-timeout>=3.0.1 (optional)
- trio>=0.16.0 (optional)
- curio>=1.4 (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]
to include optional curio support:
pip install httpx-socks[curio]
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.5.1.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for httpx_socks-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e35faf73be96cdc2d8384a8c92b9bc8d564fe69f4dae3d1e534239f3eed903c |
|
MD5 | e30a4bbbb13a7ccc10dc91676ad4fdd4 |
|
BLAKE2b-256 | ba4925e25239a1b6110ff53e3db92247b84907be3cae97b6287b09ecda5c591a |