From a23708900ec57dac0b70ee0a63081a14ad733ae6 Mon Sep 17 00:00:00 2001 From: lzybetter Date: Sat, 9 Sep 2023 16:25:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4requests=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- util/requests_with_proxy.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 789ef31..8cbdbf5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ test.py *.db ## user file -token_cache.bin +custom_plugins/microsoft_todo/token_cache.bin ### plugin file custom_plugins/* diff --git a/util/requests_with_proxy.py b/util/requests_with_proxy.py index c8e7e45..0708d7e 100644 --- a/util/requests_with_proxy.py +++ b/util/requests_with_proxy.py @@ -32,12 +32,13 @@ class RequestWithProxy: if self.__no_proxy: os.environ['NO_PROXY'] = ','.join(self.__no_proxy) - def get(self, url, headers=None): + def get(self, url, **kwargs): try: - if url.replace("https://", "").replace("http://", "").splice('/')[0] in self.__no_proxy: - r = requests.get(url=url, headers=headers) + if url.replace("https://", "").replace("http://", "").split('/')[0] in self.__no_proxy: + r = requests.get(url=url, **kwargs) else: - r = requests.get(url=url, headers=headers, proxies=self.__proxies) + kwargs['proxies'] = self.__proxies + r = requests.get(url=url, **kwargs) return r except: return None