2017-05-25 94 views
1

我已經在文檔中使用了相同的代碼,但是使用設置實例化Crawlrunner的小差異,以便它不會錯過管道操作。如果不使用它,它將正常工作,但將跳過管道。在scrapy中使用CrawlerRunner的ReactorNotRestartable錯誤

from twisted.internet import reactor 
import scrapy 
from scrapy.crawler import CrawlerRunner 
from scrapy.utils.log import configure_logging 
from forspef_scrapper import ForspefScrapper 
from scrapy.utils.project import get_project_settings 

configure_logging({'LOG_FORMAT': '%(levelname)s: %(message)s'}) 
runner = CrawlerRunner(get_project_settings()) 

d = runner.crawl(ForspefScrapper) 
d.addBoth(lambda _: reactor.stop()) 
reactor.run() 

請建議此原因和可能的修復。

回答

0

刪除reactor.stop的回調,您不應再看到該問題。該反應堆設計爲始終運行

+0

感謝您的建議,但我需要在循環中運行蜘蛛,如果回調被刪除,那麼它不會停止爬蟲。 – Lonewolf

+0

您的項目中的其他任何地方是否有'reactor.stop'? –