python 爬虫 HTML 乱码
请问各位这种html乱码是需要解压缩吗,还是其他原因导致的!
import requests
url=’https://movie.douban.com/top250'
header={ ‘Accept’:’text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,imag e/apng,/;q=0.8’,
‘Accept-Encoding’:’gzip,deflate,br’,
‘Accept-Language’:’zh-CN,zh;q=0.9’,
‘Cache-Control’:’max-age=0’,
‘Connection’:’keep-alive’,
‘Host’:’movie.douban.com’,
‘Upgrade-Insecure-Requests’:’1’,
‘User-Agent’:’Mozilla/5.0(Windows NT 6.1;WOW64)AppleWebKit/537.36(KHTML,like Gecko)Chrome/63.0.3239.132 Safari/537.36’,
}
response=requests.get(url=url,headers=header)
response.encoding=’utf-8’
print(response.text)
推荐文章: