This commit is contained in:
caiwx86 2023-01-10 01:36:12 +08:00
parent 0c9c82e375
commit 906184f8c6
2 changed files with 13 additions and 4 deletions

View File

@ -1,8 +1,13 @@
import os
from utils.entity.RouMan import comicEntity
#from utils.entity.JMTI import comicEntity
def comics():
for x in range(0,50):
comicEntity.downladsComcis("https://rm01.xyz/books?&page="+str(x))
if __name__ == '__main__':
comics()
#comics()
# os.environ["http_proxy"] = "http://127.0.0.1:7890"
# os.environ["https_proxy"] = "http://127.0.0.1:7890"
# comicEntity.oneComic("https://18comic.vip/album/358870/")

View File

@ -51,7 +51,8 @@ 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,
status_forcelist=[ 500, 502, 503, 504 ])
@ -60,7 +61,8 @@ class htmlUtils:
s.mount('https://', HTTPAdapter(max_retries=retries))
count = 1
#数据为空则获取数据
url_text = cls.getPathSaveHtml(curl,"read")
if not update:
url_text = cls.getPathSaveHtml(curl,"read")
if url_text != None:
return html.fromstring(url_text)
while url_text == None:
@ -119,7 +121,9 @@ class htmlUtils:
except:
ntfy.sendMsg(f"html_cache更新失败 {html_cache_path}")
#获取html实体数据
et = cls.getHTML(url)
et = cls.getHTML(url,update=update)
if et == None:
return None
#比对数据
count = 1
xpaths = et.xpath(c_xpath)