在pycharm中print(response.text)时报错

来源:2-7 spider文件的编写(2)

小鱼儿丶

2018-10-08 17:33

2018-10-08 09:21:06 [scrapy.core.scraper] ERROR: Spider error processing <GET https://movie.douban.com/top250> (referer: None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/twisted/internet/defer.py", line 654, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/home/xiaoyuer/PycharmProjects/douban/douban/spiders/douban_spider.py", line 11, in parse
    print(response.text)
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 345-348: ordinal not in range(256)

在终端中可以打印出来的,不知道怎么就编码错误了

写回答 关注

1回答

  • 小鱼儿丶
    2018-10-08 20:53:12

    改下settings中的encoding就行了。自己犯傻了0.0

Python最火爬虫框架Scrapy入门与实践

做为爬虫工程师Python Scrapy主流爬虫框架你必须要会!

67418 学习 · 223 问题

查看课程

相似问题