Skip to content

Commit

Permalink
fix html encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Oct 6, 2024
1 parent a236730 commit 0677015
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion novel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Expand Down

0 comments on commit 0677015

Please sign in to comment.