romis2012/httpx-socks
Fork: 6 Star: 65 (更新于 1970-01-01 00:00:00)
license: Apache-2.0
Language: Python .
Proxy (HTTP, SOCKS) transports for httpx
最后发布版本: v0.8.0 ( 2023-11-05 20:34:09)
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
最近版本更新:(数据更新于 1970-01-01 00:00:00)
2023-11-05 20:34:09 v0.8.0
2023-09-14 18:00:59 v0.7.8
2023-07-06 19:59:09 v0.7.7
2023-04-16 13:46:04 v0.7.6
2022-11-22 22:22:34 v0.7.5
2022-05-25 17:58:35 v0.7.4
2022-01-27 17:20:16 v0.7.3
2021-11-25 20:23:28 v0.7.2
2021-11-25 18:47:59 v0.7.1
2021-11-23 21:34:29 v0.7.0
主题(topics):
asyncio, http, httpx, proxy, python, socks4, socks5, trio
romis2012/httpx-socks同语言 Python最近更新仓库
2024-11-22 02:39:01 goauthentik/authentik
2024-11-22 00:03:47 comfyanonymous/ComfyUI
2024-11-21 22:06:18 rashevskyv/dbi
2024-11-21 21:09:02 xtekky/gpt4free
2024-11-21 20:03:58 ultralytics/ultralytics
2024-11-21 00:54:04 hect0x7/JMComic-Crawler-Python