This commit is contained in:
caiwx86 2022-12-08 08:19:26 +08:00
parent 0eea194268
commit e0ad6a64d5

View File

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