This commit is contained in:
caiwx86 2023-01-15 21:54:21 +08:00
parent fd728724c1
commit 934d753778
2 changed files with 6 additions and 8 deletions

View File

@ -51,7 +51,7 @@ class htmlUtils:
print()
@classmethod
def getHTML(cls, curl,type=None):
def getHTML(cls, curl,type=None,update=False):
url_text = None
retries = Retry(total=1,
backoff_factor=0.1,
@ -65,9 +65,7 @@ class htmlUtils:
url_text = cls.getPathSaveHtml(curl,"read")
except:
url_text = None
if url_text != None:
return html.fromstring(url_text)
while url_text == None:
while url_text == None or update:
if count <= 5:
try:
print(f"请求地址:{curl}")
@ -97,15 +95,15 @@ class htmlUtils:
ntfy.sendMsg(f"fail 请求失败:{curl}")
exit()
break
return url_text
return html.fromstring(url_text)
@classmethod
def getBytes(cls, url):
return cls.getHTML(url,type="bytes")
@classmethod
def getJSON(cls,url):
return cls.getHTML(url,type="json")
def getJSON(cls,url,update=False):
return cls.getHTML(url,type="json",update=update)
@classmethod
def xpathData(cls,c_xpath,url=None,num=None,not_eq=None,update=False):

View File

@ -34,7 +34,7 @@ class comicCommon:
base_url = comicInfo.getBaseUrl(chapter_url)
chapter_api_url = base_url+chapter_api_path
ntfy.sendMsg(f"chapterApiUrl= {chapter_api_url}",alert=False)
data = htmlUtils.getJSON(chapter_api_url)
data = htmlUtils.getJSON(chapter_api_url,update=True)
if data != None:
data = data.get("chapter")
chapter_name = data.get("name")