diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index fd014af..f9cdb23 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -53,19 +53,15 @@ class htmlUtils: @classmethod def getJSON(cls,curl): - count = 1 - data_json = None - while count < 5: + while True: try: res = requests.get(curl, headers=cls.headers,timeout=30) data_json = res.json() + return data_json except: - count += 1 - print(f"请求失败,第{count}次重试中...") + print(f"请求失败,重试中...") time.sleep(1) - res = requests.get(curl, headers=cls.headers,timeout=30) - data_json = res.json() - return data_json + cls.getJSON(curl) @classmethod def xpathData(cls,c_xpath,url=None,num=None,not_eq=None):