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.21.*
- python-socks>=1.2.4
- async-timeout>=3.0.1 (optional)
- trio>=0.16.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
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.7.2.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for httpx_socks-0.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44d5f3bf5f4db3d73a0d4fa81feabe215de5d9546c44a575ab8a49c943821722 |
|
MD5 | 8f041f02c2bb5741f78cdb3c97b98706 |
|
BLAKE2b-256 | a8b40e283796f93e8d044767a6631917a8533898b6ce3a5e32cf0a2d8852036d |