diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index a07c18a..b2a5988 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -53,7 +53,7 @@ class htmlUtils: @classmethod def getHTML(cls, curl,type=None,update=False): url_text = None - retries = Retry(total=1, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ]) + retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ]) s = requests.Session() s.mount('http://', HTTPAdapter(max_retries=retries)) s.mount('https://', HTTPAdapter(max_retries=retries)) @@ -64,7 +64,6 @@ class htmlUtils: if url_text != None and update == False: return html.fromstring(url_text) else: url_text = None while url_text == None: - if count <= 5: try: print(f"请求地址:{curl}") res = s.get(curl,stream=True, headers=cls.headers, timeout=10,allow_redirects=True) @@ -84,11 +83,7 @@ class htmlUtils: print(f'Retry! 第{count}次') cls.remove_HtmlCache(curl) time.sleep(1) - count += 1 continue - else: - ntfy.sendMsg(f"fail 请求失败:{curl}") - break return url_text @classmethod