我已经看到了类似的问题并尝试了答案,但无济于事。有人可以帮我纠正这个吗?
由于
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'
答案 0 :(得分:12)
您应该使用spider name,而不是脚本名称。
例如,如果您有以下蜘蛛:
class MySpider(CrawlSpider):
name = "myspider"
...
在这种情况下,您可以将其运行为:
scrapy crawl myspider