出现问题如下:
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_deferredresult = f(*args, **kw)File "C:\Users\admin\Desktop\crawler_scrapy_us\venv\lib\site-packages\scrapy\core\spidermw.py", line 92, in _process_spider_inputreturn 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_spiderwarn_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_valueif 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_valuesrc = inspect.getsource(func)File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 1139, in getsourcelines, lnum = getsourcelines(object)File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 1121, in getsourcelineslines, lnum = findsource(object)File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\inspect.py", line 958, in findsourceraise OSError('could not get source code')
OSError: could not get source code
原因:想必是你小子手动创建了爬虫文件,这样出现了编码问题
解决办法:爬虫文件添加编码头注释
#coding=utf8
#coding=utf8
import scrapy