我需要帮助来安排我的蜘蛛每N分钟运行一次。早期我看到大多数人为此目的使用了reactor.callLater
和reactor.run
,但似乎现在没有可能使用这些功能。我该如何安排程序化?
def run_crawl():
"""
Run a spider within Twisted. Once it completes,
wait 5 seconds and run another spider.
"""
runner = CrawlerRunner(get_project_settings())
runner.crawl(SpiderA)
runner.crawl(SpiderB)
deferred = runner.join()
deferred.addCallback(reactor.callLater, 5, run_crawl)
return deferred
run_crawl()
reactor.run()
此时我的爬虫程序由Windows任务计划程序安排,但我想以编程方式安排它。