若从headers和meta获取不到编码,用r.apparent_encoding获取

This commit is contained in:
g1879 2020-08-15 23:05:22 +08:00
parent da079ce7b7
commit adeba1fec6

View File

@ -364,7 +364,7 @@ class SessionPage(object):
try: try:
charset = re_result.group(1) charset = re_result.group(1)
except: except:
charset = 'utf-8' charset = r.apparent_encoding
else: else:
charset = headers['Content-Type'].split('=')[1] charset = headers['Content-Type'].split('=')[1]
# 避免存在退格符导致乱码或解析出错 # 避免存在退格符导致乱码或解析出错