From 775c0c996f2fa30792adb3fffc402b52523ee33e Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Fri, 23 Dec 2022 00:40:28 +0800 Subject: [PATCH] fix --- utils/HtmlUtils.py | 5 ++++- utils/entity/RouMan.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/HtmlUtils.py b/utils/HtmlUtils.py index 1d18d5e..85edfe0 100644 --- a/utils/HtmlUtils.py +++ b/utils/HtmlUtils.py @@ -93,7 +93,10 @@ class htmlUtils: @classmethod def getJSON(cls,url): url_text = requests.get(url,headers=cls.headers, timeout=180).text - return json.loads(url_text) + try: + return json.loads(url_text) + except: + return None #return cls.getHTML(url,type="json") @classmethod diff --git a/utils/entity/RouMan.py b/utils/entity/RouMan.py index ec14307..73b5a7f 100644 --- a/utils/entity/RouMan.py +++ b/utils/entity/RouMan.py @@ -182,10 +182,10 @@ class comicEntity: chapterAPIUrl = base_url+chapterAPIPath ntfy.sendMsg(f"chapterApiUrl= {chapterAPIUrl}") data = htmlUtils.getJSON(chapterAPIUrl) - print(data) - data = data.get("chapter") - chapterName = data.get("name") - images = data.get("images") + if data != None: + data = data.get("chapter") + chapterName = data.get("name") + images = data.get("images") if images == None: ntfy.sendMsg(f"未获取到章节图像 comic_name={bookName} chapter={chapterName}")