From f2eebff1632c77881621bbf6b10ca2842a53db6f Mon Sep 17 00:00:00 2001 From: yoshiko2 Date: Tue, 4 May 2021 01:32:17 +0800 Subject: [PATCH] Fix jav321 Exception handling #2 --- WebCrawler/jav321.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WebCrawler/jav321.py b/WebCrawler/jav321.py index f8d7e7b..e3732c5 100644 --- a/WebCrawler/jav321.py +++ b/WebCrawler/jav321.py @@ -10,13 +10,12 @@ import re def main(number: str) -> json: try: result = post_html(url="https://www.jav321.com/search", query={"sn": number}) + soup = BeautifulSoup(result.text, "html.parser") + lx = html.fromstring(str(soup)) 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)) - if "/video/" in result.url: data = parse_info(soup)