【问题标题】:Scrapy error: Spider not FoundScrapy错误:未找到蜘蛛
【发布时间】:2014-07-14 14:17:52
【问题描述】:

我已经看到了一个类似的问题,并尝试了给出的答案,但无济于事。有人可以帮我纠正这个吗?

谢谢

hepz@ubuntu:~/Documents/project/project$ scrapy crawl NewsSpider.py
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 4, in <module> 
execute()
File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 143, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 89, in _run_print_help
func(*a, **kw)
File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 150, in _run_command
cmd.run(args, opts)
File "/usr/local/lib/python2.7/dist-packages/scrapy/commands/crawl.py", line 58, in run
spider = crawler.spiders.create(spname, **opts.spargs)
File "/usr/local/lib/python2.7/dist-packages/scrapy/spidermanager.py", line 44, in create
raise KeyError("Spider not found: %s" % spider_name)
KeyError: 'Spider not found: NewsSpider.py'

【问题讨论】:

    标签: python web-scraping scrapy scrapy-spider


    【解决方案1】:

    您应该使用spider name,而不是脚本名称。

    例如,如果您有以下蜘蛛:

    class MySpider(CrawlSpider):
        name = "myspider"
        ...
    

    在这种情况下,您可以这样运行它:

    scrapy crawl myspider
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-21
      • 2010-12-20
      • 2011-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多