问答详情
源自:2-7 spider文件的编写(2)

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

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)

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

提问者:小鱼儿丶 2018-10-08 17:33

个回答

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

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