最近遇到爬取网页乱码的情况,找了好久找到了种解决的办法:

html = requests.get(url,headers = head)
html.apparent_encoding
html.encoding = html.apparent_encoding
print html.text

头文件中添加:

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-11-27
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2021-11-17
  • 2021-10-21
  • 2022-12-23
  • 2021-10-09
  • 2021-12-25
相关资源
相似解决方案