diff --git a/novel/main.py b/novel/main.py index 5eade54..c937f76 100644 --- a/novel/main.py +++ b/novel/main.py @@ -103,6 +103,7 @@ def load_cache(): def get_url_html(url, proxy=None): try: request = requests.get(url, impersonate="chrome", proxies=proxy) + request.encoding = "gbk" return request.text except Exception as e: @@ -113,7 +114,6 @@ def get_url_html(url, proxy=None): def extract_book_title(html): try: - html.encoding = "gbk" tree = etree.HTML(html, parser=None) div_element = tree.xpath('//div[contains(@class, "qustime")]')[0] span_element = div_element.xpath("./ul/li[1]/a/span")[0]