From 5fd3358ed95c72dcaa4d266b5fb65a1361735636 Mon Sep 17 00:00:00 2001 From: JoeamAmier Date: Tue, 22 Aug 2023 20:39:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Html.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/Html.py b/source/Html.py index 0e885ec..fc93b58 100644 --- a/source/Html.py +++ b/source/Html.py @@ -1,4 +1,5 @@ import requests +from requests import get class Html: @@ -12,12 +13,21 @@ class Html: params=None, proxies=None, timeout=10, - **kwargs): - response = requests.get( - url, - params=params, - proxies=proxies, - timeout=timeout, - headers=self.headers, - **kwargs) + **kwargs) -> str: + try: + response = get( + url, + params=params, + proxies=proxies, + timeout=timeout, + headers=self.headers, + **kwargs) + except ( + requests.exceptions.ProxyError, + requests.exceptions.SSLError, + requests.exceptions.ChunkedEncodingError, + requests.exceptions.ConnectionError, + requests.ReadTimeout, + ): + return "" return response.text