解码兼容处理

This commit is contained in:
Jing Ling
2020-01-23 15:57:32 +08:00
parent 67937a6313
commit 65a64e3929
+3 -3
View File
@@ -92,9 +92,9 @@ async def fetch(session, url):
proxy=config.get_proxy) as resp: proxy=config.get_proxy) as resp:
try: try:
text = await resp.text(encoding='gb18030') # 先尝试用gb18030解码 text = await resp.text(encoding='utf-8', errors='replace') # 先尝试用utf-8解码
except UnicodeDecodeError: except UnicodeError:
text = await resp.text(encoding='utf-8', errors='ignore') text = await resp.text(encoding='gb18030', errors='replace')
return resp, text return resp, text
except Exception as e: except Exception as e:
return e return e