一、问题
request.Request(url,headers=headerDict))的时候出现异常信息:'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
二、解决方案
http头中headerDict参数: "Accept-Encoding": "gzip, deflate",
代表本地可以接收压缩格式的数据,而服务器在处理时就将大文件压缩再发回客户端,IE在接收完成后在本地对这个文件又进行了解压操作。
出错的原因是因为你的程序没有解压这个文件,所以删掉这行就不会出现问题。
https://blog.youkuaiyun.com/zhang_cl_cn/article/details/94575568
Python模块Requests的中文乱码问题
from:http://blog.youkuaiyun.com/chaowanghn/article/details/54889835
解决Requests中文乱码
都在推荐用Requests库,而不是Urllib,但是读取网页的时候中文会出现乱码。
分析:
r = requests.get(“http://www.baidu.com“)
**r.text返回的是Unicode型的数据。
使用r.content返回的是bytes型的数据。
也就是说,如果你想取文本,可以通过r.t