Ich habe zwei Spinnen in einer Datei geschrieben. Als ich lief, wurde nur der erste Spider ausgeführt. Wie kann ich beide ausführen, ohne die Datei in zwei Dateien aufzuteilen?Scrapy legte zwei Spinnen in eine Datei
two_spiders.py:
import scrapy
class MySpider1(scrapy.Spider):
# first spider definition
...
class MySpider2(scrapy.Spider):
# second spider definition
...
Fehler aufgetreten, wie ich folgen @llya beantworten
2016-03-23 19:48:52 [scrapy] INFO: Scrapy 1.0.5 started (bot: scrapybot)
2016-03-23 19:48:52 [scrapy] INFO: Optional features available: ssl, http11
2016-03-23 19:48:52 [scrapy] INFO: Overridden settings: {}
2016-03-23 19:48:54 [scrapy] INFO: Scrapy 1.0.5 started (bot: scrapybot)
2016-03-23 19:48:54 [scrapy] INFO: Scrapy 1.0.5 started (bot: scrapybot)
2016-03-23 19:48:54 [scrapy] INFO: Optional features available: ssl, http11
2016-03-23 19:48:54 [scrapy] INFO: Optional features available: ssl, http11
...
scrapy runspider two_spiders.py
Traceback (most recent call last):
File "/opt/pyenv.agutong-scrapy/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/scrapy/cmdline.py", line 143, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/scrapy/cmdline.py", line 89, in _run_print_help
func(*a, **kw)
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/scrapy/cmdline.py", line 150, in _run_command
cmd.run(args, opts)
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/scrapy/commands/runspider.py", line 89, in run
self.crawler_process.start()
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/scrapy/crawler.py", line 251, in start
reactor.run(installSignalHandlers=False) # blocking call
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/twisted/internet/base.py", line 1193, in run
self.startRunning(installSignalHandlers=installSignalHandlers)
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/twisted/internet/base.py", line 1173, in startRunning
ReactorBase.startRunning(self)
File "/opt/pyenv.agutong-scrapy/lib/python2.7/site-packages/twisted/internet/base.py", line 684, in startRunning
raise error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable
Warum möchten Sie sie in einer Datei? –