mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
✨ 更新 get_async_client 函数,支持字符串类型的代理参数
- 修改 proxies 参数类型,允许传入字符串形式的代理地址 - 增强代理处理逻辑,将字符串代理转换为字典格式,提升灵活性和可用性
This commit is contained in:
parent
d6b687ceb0
commit
f9b705aedd
@ -98,7 +98,7 @@ def get_client() -> AsyncClient:
|
||||
|
||||
|
||||
def get_async_client(
|
||||
proxies: dict[str, str] | None = None,
|
||||
proxies: dict[str, str] | str | None = None,
|
||||
proxy: str | None = None,
|
||||
verify: bool = False,
|
||||
**kwargs,
|
||||
@ -109,6 +109,8 @@ def get_async_client(
|
||||
"""
|
||||
transport = kwargs.pop("transport", None) or AsyncHTTPTransport(verify=verify)
|
||||
if proxies:
|
||||
if isinstance(proxies, str):
|
||||
proxies = {"http://": proxies, "https://": proxies}
|
||||
http_proxy = proxies.get("http://")
|
||||
https_proxy = proxies.get("https://")
|
||||
return httpx.AsyncClient(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user