httpx-socks 0.10.0
pip install httpx-socks
Latest version
Released:
Proxy (HTTP, SOCKS) transports for httpx
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Apache 2
- Author: Roman Snegirev
- Tags httpx, asyncio, socks, socks5, socks4, http, proxy
Project description
httpx-socks
The httpx-socks
package provides proxy transports for httpx client.
SOCKS4(a), SOCKS5(h), HTTP (tunneling) proxy supported.
It uses python-socks for core proxy functionality.
Requirements
- Python >= 3.6
- httpx>=0.21.0
- python-socks>=2.0.0
- 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
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
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: Apache 2
- Author: Roman Snegirev
- Tags httpx, asyncio, socks, socks5, socks4, http, proxy
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
Built Distribution
File details
Details for the file httpx_socks-0.10.0.tar.gz
.
File metadata
- Download URL: httpx_socks-0.10.0.tar.gz
- Upload date:
- Size: 93.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e232e31174de79cc79ca7174bbc159aabb4b95e0ff5cc2d894d33f6cbe1a1096 |
|
MD5 | f05a60d00368d8ca8dea2797a490f822 |
|
BLAKE2b-256 | 26a4b93909386d9bfc9d43fbb4a35bc33936ff5e6952d03aba8958af3b7dfada |
File details
Details for the file httpx_socks-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: httpx_socks-0.10.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9345572cc1b279c0878ab976c654a78d9b4b7b446183ec1e03569a480021addb |
|
MD5 | bd82695aa25dacc79614144df64975f4 |
|
BLAKE2b-256 | 9dfcf55d40f5c158c7acf7a45771019c75a41de756c0a9af6139155a322258f8 |