From 0677015faf0700bb1e56e66eb00f319b79dc9247 Mon Sep 17 00:00:00 2001 From: sgrtye Date: Sun, 6 Oct 2024 22:14:41 +0100 Subject: [PATCH] fix html encoding --- novel/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]