diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index 1252d68..e1a130e 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -63,9 +63,12 @@ class htmlUtils: except: url_text = None if url_text != None and update == False: return html.fromstring(url_text) else: url_text = None - while url_text == None: + repeat = 0 + while url_text == None and repeat <=5: + repeat+=1 print(f"请求地址:{curl}") - res = s.get(curl,stream=True, headers=cls.headers, timeout=5,allow_redirects=True) + try: res = s.get(curl,stream=True, headers=cls.headers, timeout=5,allow_redirects=True) + except: print(f"请求失败:{curl}") if type == "bytes": url_text = res if type == "json":