fix: 修复字符集不匹配的情况提取web的问题

--bug=1048607 --user=刘瑞斌 【github#1577】有个网站导入web知识库报错 https://www.tapd.cn/57709429/s/1623295
This commit is contained in:
CaptainB 2024-12-03 14:57:54 +08:00 committed by 刘瑞斌
parent b572956da6
commit 695576bfbd

View File

@ -142,7 +142,10 @@ class Fork:
if len(charset_list) > 0:
charset = charset_list[0]
if charset != encoding:
html_content = response.content.decode(charset)
try:
html_content = response.content.decode(charset)
except Exception as e:
logging.getLogger("max_kb").error(f'{e}')
return BeautifulSoup(html_content, "html.parser")
return beautiful_soup