mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🚨 auto fix by pre-commit hooks
This commit is contained in:
parent
1a69f95146
commit
d80e15de2b
@ -23,8 +23,10 @@ from zhenxun.utils.user_agent import get_user_agent
|
|||||||
|
|
||||||
# from .browser import get_browser
|
# from .browser import get_browser
|
||||||
|
|
||||||
|
|
||||||
def get_async_client(proxies=None, **kwargs):
|
def get_async_client(proxies=None, **kwargs):
|
||||||
from httpx._config import create_ssl_context
|
from httpx._config import create_ssl_context
|
||||||
|
|
||||||
context = create_ssl_context(
|
context = create_ssl_context(
|
||||||
verify=kwargs.get("verify", True),
|
verify=kwargs.get("verify", True),
|
||||||
cert=kwargs.get("cert"),
|
cert=kwargs.get("cert"),
|
||||||
@ -35,10 +37,18 @@ def get_async_client(proxies=None, **kwargs):
|
|||||||
try:
|
try:
|
||||||
return httpx.AsyncClient(proxies=proxies, **kwargs)
|
return httpx.AsyncClient(proxies=proxies, **kwargs)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return httpx.AsyncClient(mounts={
|
return httpx.AsyncClient(
|
||||||
"http://": httpx.AsyncHTTPTransport(proxy=proxies.get("http")) if proxies else None,
|
mounts={
|
||||||
"https://": httpx.AsyncHTTPTransport(proxy=proxies.get("https")) if proxies else None
|
"http://": httpx.AsyncHTTPTransport(proxy=proxies.get("http"))
|
||||||
}, **kwargs)
|
if proxies
|
||||||
|
else None,
|
||||||
|
"https://": httpx.AsyncHTTPTransport(proxy=proxies.get("https"))
|
||||||
|
if proxies
|
||||||
|
else None,
|
||||||
|
},
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AsyncHttpx:
|
class AsyncHttpx:
|
||||||
proxy: ClassVar[dict[str, str | None]] = {
|
proxy: ClassVar[dict[str, str | None]] = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user