From c3dbfda098bf9d5dcae4ce1e217766e1d51a5927 Mon Sep 17 00:00:00 2001 From: Mitsumune <59498164+acgloli@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dself.proxy=E4=B8=BANone?= =?UTF-8?q?=E6=97=B6=E4=BA=A7=E7=94=9F=E7=9A=84=E6=8A=A5=E9=94=99=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- live_recorder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/live_recorder.py b/live_recorder.py index 9a98313..f737ade 100644 --- a/live_recorder.py +++ b/live_recorder.py @@ -71,11 +71,17 @@ async def request(self, method, url, **kwargs): raise ConnectionError(f'{self.flag}直播检测请求错误\n{repr(error)}') def get_client(self): + # 检查是否有设置代理 + if self.proxy: + transport = AsyncProxyTransport.from_url(self.proxy) + else: + transport = None + return httpx.AsyncClient( http2=True, timeout=self.interval, limits=httpx.Limits(max_keepalive_connections=100, keepalive_expiry=self.interval * 2), - transport=AsyncProxyTransport.from_url(self.proxy), + transport=transport, headers=self.headers, cookies=self.cookies )