Python HTTP库requests中文页面乱码解决方案!
2017-06-28 11:15
141 查看
把html编码类型赋与获取到文本
获取html编码类型:
1.使用apparent_encoding可以获得真实编码
1 >>> response.apparent_encoding 2 'GB2312'
2.从html的meta中抽取
1 >>> requests.utils.get_encodings_from_content(response.text) 2 ['gb2312']
前戏结束,只出一招即可(随意选用):
1 # response.encoding = response.apparent_encoding 2 response.encoding = 'gb2312
相关文章推荐
- Python HTTP库requests中文页面乱码解决方案!
- Python HTTP库requests中文页面乱码解决方案!
- 用XMLHTTP Post/Get HTML页面时的中文乱码问题之完全Script解决方案
- JSP页面出现中文乱码的两种解决方案
- 关于JSP页面包含HTML文件时中文出现乱码的强力解决方案!
- HtmlAgilityPack 抓取中文页面乱码问题的解决方案
- JSP页面显示中文乱码的解决方案
- XMLHTTP Get HTML页面时的中文乱码之完全客户端Script解决方案
- JS中页面跳转,传值包含中文时乱码解决方案
- HtmlAgilityPack 加载中文页面时出现在乱码的最终解决方案
- javascript通过url向jsp页面传递中文参数导致乱码解决方案
- 用XMLHTTP Post/Get HTML页面时的中文乱码之完全Script解决方案
- 用XMLHTTP Post/Get HTML页面时的中文乱码问题之完全Script解决方案
- JAVA 页面传值 get方式提交 中文乱码问题的解决方案
- javascript通过url向jsp页面传递中文参数导致乱码解决方案
- XMLHTTP Get HTML页面时的中文乱码之完全客户端Script解决方案
- JSP页面间的中文传值乱码问题,解决方案
- HtmlAgilityPack 抓取中文页面乱码问题的解决方案
- 页面传值中文乱码解决方案
- JS中页面跳转,传值包含中文时乱码解决方案