刚进行对Python爬虫的学习在中文编码上踩了大坑,不过最近的尝试发现,如果Html编码类型为gb2312,
而你的程序则是utf-8的编码
实际上可以如下操作
# -*- encoding= "utf-8" -*-
import requests
url="http://top.baidu.com/buzz?b=1&fr=topindex"
rep0=requests.get(url)
rep0.encoding="gb2312"
print(rep0.text)
这样就不会出现乱码了,不过还没试过其他有些网站,之后在做补充
2018.5.22