KeyError:未找到蜘蛛[Scrapy]

时间:2016-04-15 14:12:12

标签: python scrapy web-crawler scrapy-spider

我有两只蜘蛛,它们都有相同的名字(错误的是人类)。

class ProductSpider(scrapy.Spider):
    name = 'Product'

当我爬行时,两只蜘蛛都爬了。

所以,当我更改其中一个蜘蛛的名称(另一个蜘蛛仍然具有相同的名称Product)时:

scrapy crawl Product

我收到以下错误:

Traceback (most recent call last):
  File "/usr/local/bin/scrapy", line 11, in <module>
    sys.exit(execute())
  File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 143, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 89, in _run_print_help
    func(*a, **kw)
  File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 150, in _run_command
    cmd.run(args, opts)
  File "/Library/Python/2.7/site-packages/scrapy/commands/crawl.py", line 57, in run
    self.crawler_process.crawl(spname, **opts.spargs)
  File "/Library/Python/2.7/site-packages/scrapy/crawler.py", line 150, in crawl
    crawler = self._create_crawler(crawler_or_spidercls)
  File "/Library/Python/2.7/site-packages/scrapy/crawler.py", line 165, in _create_crawler
    spidercls = self.spider_loader.load(spidercls)
  File "/Library/Python/2.7/site-packages/scrapy/spiderloader.py", line 40, in load
    raise KeyError("Spider not found: {}".format(spider_name))
KeyError: 'Spider not found: Product'



但是,在调试时,当我将名称Product更改为随机的新名称foo时,它可以正常工作。

我不明白。为什么会这样?

0 个答案:

没有答案
相关问题