在scrapy项目中,由于编码问题,下载的网页中中文都是utf-8编码,在Pipeline.py中方法process_item将结果保存到数据库中时,提示UnicodeDecodeError: 'utf8' codec can't decode byte  in position  invalid start byte

解决方法:在Pipeline.py里增加如下代码。

 

import sys


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

 

相关文章:

  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
  • 2021-04-01
  • 2022-01-19
猜你喜欢
  • 2022-12-23
  • 2021-04-21
  • 2022-01-07
  • 2021-11-19
  • 2021-06-15
  • 2021-06-11
  • 2021-09-28
相关资源
相似解决方案