fix gansudaily econding bug

This commit is contained in:
baoliang 2021-01-26 12:23:57 +08:00
parent fb8ac287a9
commit e2f0507e68
1 changed files with 4 additions and 2 deletions

View File

@ -97,11 +97,13 @@ def parse(url):
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
}
r = requests.get(url, headers=headers)
if r.encoding=='ISO-8859-1':
print(r.encoding)
if t == 'xgs' and r.encoding=='ISO-8859-1':
r.encoding='GBK'
else:
r.encoding = 'utf-8'
# print(r.text)
# way2@8797799
selector = Selector(text=r.text)
if t == 'weixin':
og_title = selector.xpath(