Scrapy Spider 未找到错误 [英] Scrapy spider not found error

查看:53
本文介绍了Scrapy Spider 未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是带有 python 2.7 的 Windows 7

This is Windows 7 with python 2.7

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

I have a scrapy project in a directory called caps (this is where scrapy.cfg is)

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

My spider is located in caps\caps\spiders\campSpider.py

我进入scrapy项目并尝试运行

I cd into the scrapy project and try to run

scrapy crawl campSpider -o items.json -t json

我收到一个错误,提示无法找到蜘蛛.类名 campSpider

I get an error that the spider can't be found. The class name is 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'

我是否遗漏了一些配置项?

Am I missing some configuration item?

推荐答案

确保您已经设置了蜘蛛的 "name" 属性.示例:

Make sure you have set the "name" property of the spider. Example:

class campSpider(BaseSpider):
   name = 'campSpider'

如果没有 name 属性,scrapy 管理器将无法找到您的蜘蛛.

Without the name property, the scrapy manager will not be able to find your spider.

这篇关于Scrapy Spider 未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆