修复正则有些情况下获取不到charset的bug

This commit is contained in:
g1879 2020-06-04 23:28:18 +08:00
parent 3d04ab1405
commit f1394d4cdd

View File

@ -218,7 +218,7 @@ class SessionPage(object):
else:
headers = dict(r.headers)
if 'Content-Type' not in headers or 'charset' not in headers['Content-Type']:
re_result = re.search(r'<meta.*?charset=([^"\']+)', r.text)
re_result = re.search(r'<meta.*?charset= *([^"\' />]+).*?>', r.text)
try:
charset = re_result.group(1)
except: