This commit is contained in:
caiwx86 2023-04-01 21:04:33 +08:00
parent 263d8c578f
commit 42aa15a196

View File

@ -65,18 +65,20 @@ class htmlUtils:
else: url_text = None
repeat = 0
while url_text == None and repeat <=5:
repeat+=1
print(f"请求地址:{curl}")
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":
cls.saveHtml(curl,res.text,type="json")
return json.loads(res.text)
if type == None:
url_text = html.fromstring(res.text)
cls.saveHtml(curl,res.text)
try:
print(f"请求地址:{curl}")
res = s.get(curl,stream=True, headers=cls.headers, timeout=5,allow_redirects=True)
if type == "bytes":
url_text = res
if type == "json":
cls.saveHtml(curl,res.text,type="json")
return json.loads(res.text)
if type == None:
url_text = html.fromstring(res.text)
cls.saveHtml(curl,res.text)
except:
repeat += 1
ntfy.sendMsg(f"请求失败:{curl}",sleep=1)
return url_text
@classmethod