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()
請建議此原因和可能的修復。
感謝您的建議,但我需要在循環中運行蜘蛛,如果回調被刪除,那麼它不會停止爬蟲。 – Lonewolf
您的項目中的其他任何地方是否有'reactor.stop'? –