From 61432032c8c8669a0441a56f0832c57daa5d327c Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Tue, 17 Jun 2025 19:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/utils/http_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zhenxun/utils/http_utils.py b/zhenxun/utils/http_utils.py index b8c94d83..2ac982c4 100644 --- a/zhenxun/utils/http_utils.py +++ b/zhenxun/utils/http_utils.py @@ -7,7 +7,7 @@ from typing import Any, ClassVar, Literal, cast import aiofiles import httpx -from httpx import AsyncHTTPTransport, HTTPStatusError, Response +from httpx import AsyncHTTPTransport, HTTPStatusError, Proxy, Response from nonebot_plugin_alconna import UniMessage from nonebot_plugin_htmlrender import get_browser from playwright.async_api import Page @@ -36,8 +36,12 @@ def get_async_client( https_proxy = proxies.get("https://") return httpx.AsyncClient( mounts={ - "http://": AsyncHTTPTransport(proxy=http_proxy), - "https://": AsyncHTTPTransport(proxy=https_proxy), + "http://": AsyncHTTPTransport( + proxy=Proxy(http_proxy) if http_proxy else None + ), + "https://": AsyncHTTPTransport( + proxy=Proxy(https_proxy) if https_proxy else None + ), }, transport=transport, **kwargs,