fix
This commit is contained in:
parent
cf9859ce91
commit
f5d553a000
@ -53,7 +53,7 @@ class htmlUtils:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def getHTML(cls, curl,type=None,update=False):
|
def getHTML(cls, curl,type=None,update=False):
|
||||||
url_text = None
|
url_text = None
|
||||||
retries = Retry(total=1, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ])
|
retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[ 500, 502, 503, 504 ])
|
||||||
s = requests.Session()
|
s = requests.Session()
|
||||||
s.mount('http://', HTTPAdapter(max_retries=retries))
|
s.mount('http://', HTTPAdapter(max_retries=retries))
|
||||||
s.mount('https://', HTTPAdapter(max_retries=retries))
|
s.mount('https://', HTTPAdapter(max_retries=retries))
|
||||||
@ -64,7 +64,6 @@ class htmlUtils:
|
|||||||
if url_text != None and update == False: return html.fromstring(url_text)
|
if url_text != None and update == False: return html.fromstring(url_text)
|
||||||
else: url_text = None
|
else: url_text = None
|
||||||
while url_text == None:
|
while url_text == None:
|
||||||
if count <= 5:
|
|
||||||
try:
|
try:
|
||||||
print(f"请求地址:{curl}")
|
print(f"请求地址:{curl}")
|
||||||
res = s.get(curl,stream=True, headers=cls.headers, timeout=10,allow_redirects=True)
|
res = s.get(curl,stream=True, headers=cls.headers, timeout=10,allow_redirects=True)
|
||||||
@ -84,11 +83,7 @@ class htmlUtils:
|
|||||||
print(f'Retry! 第{count}次')
|
print(f'Retry! 第{count}次')
|
||||||
cls.remove_HtmlCache(curl)
|
cls.remove_HtmlCache(curl)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
count += 1
|
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
ntfy.sendMsg(f"fail 请求失败:{curl}")
|
|
||||||
break
|
|
||||||
return url_text
|
return url_text
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user