This commit is contained in:
caiwx86 2022-12-08 07:55:38 +08:00
parent 2c832f4e0a
commit c0a1bb1517

View File

@ -29,8 +29,6 @@ class htmlUtils:
try:
print("请求地址:",curl)
res = s.get(curl,stream=True, headers=cls.headers, timeout=20)
if type == "json":
url_text = res.json()
if type == "bytes":
url_text = res
else:
@ -55,7 +53,16 @@ class htmlUtils:
@classmethod
def getJSON(cls,curl):
return cls.getHTML(curl,type="json")
count = 1
data_json = None
while count < 5:
try:
res = requests.get(curl, headers=cls.headers,timeout=30)
data_json = res.json()
except:
count += 1
cls.getJSON(curl)
return data_json
@classmethod
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None):