阅读量:0
出现问题如下:
Traceback (most recent call last): File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\utils\defer.py", line 73, in mustbe_deferred result = f(*args, **kw) File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\core\spidermw.py", line 92, in _process_spider_input return scrape_func(response, request, spider) File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\core\scraper.py", line 200, in call_spider warn_on_generator_with_return_value(spider, callback) File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\utils\misc.py", line 258, in warn_on_generator_with_return_value if is_generator_with_return_value(callable): File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\utils\misc.py", line 234, in is_generator_with_return_value src = inspect.getsource(func) File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 1139, in getsource lines, lnum = getsourcelines(object) File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 1121, in getsourcelines lines, lnum = findsource(object) File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 958, in findsource raise OSError('could not get source code') OSError: could not get source code
原因:想必是你小子手动创建了爬虫文件,这样出现了编码问题
解决办法:爬虫文件添加编码头注释
#coding=utf8
#coding=utf8 import scrapy