小编典典

找不到Scrapy Spider错误

scrapy

这是Windows 7和python 2.7

我在名为caps的目录中有一个scrapy项目(这是scrapy.cfg所在的位置)

我的蜘蛛位于caps \ caps \ spiders \ campSpider.py

我进入了scrapy项目并尝试运行

scrapy crawl campSpider -o items.json -t json

我得到一个找不到蜘蛛的错误。类名是 campSpider

...
    spider = self.crawler.spiders.create(spname, **opts.spargs)
  File "c:\Python27\lib\site-packages\scrapy-0.14.0.2841-py2.7-win32.egg\scrapy\spidermanager.py", l
ine 43, in create
    raise KeyError("Spider not found: %s" % spider_name)
KeyError: 'Spider not found: campSpider'

我是否缺少一些配置项?


阅读 683

收藏
2020-04-09

共1个答案

小编典典

确保已设置spider网的“名称”属性。例:

class campSpider(BaseSpider):
   name = 'campSpider'

如果没有name属性,那么抓痒的经理将无法找到你的spider。

2020-04-09