From a088992e741d5d21eb5f4f2e43982d109a46dfc7 Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Tue, 4 May 2021 00:29:38 +0800 Subject: [PATCH] Fix jav321 Exception handling --- WebCrawler/jav321.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WebCrawler/jav321.py b/WebCrawler/jav321.py index f7c0fb4..f8d7e7b 100644 --- a/WebCrawler/jav321.py +++ b/WebCrawler/jav321.py @@ -8,7 +8,11 @@ import re def main(number: str) -> json: - result = post_html(url="https://www.jav321.com/search", query={"sn": number}) + try: + result = post_html(url="https://www.jav321.com/search", query={"sn": number}) + except: + dic = {"title": ""} + return json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':')) soup = BeautifulSoup(result.text, "html.parser") lx = html.fromstring(str(soup))