【问题标题】:Scrapy executing different spiders in different times with reactorScrapy 在不同时间使用反应器执行不同的蜘蛛
【发布时间】:2020-12-15 05:40:37
【问题描述】:

我想点击 django 网站上的一个按钮,我的蜘蛛应该开始抓取。我尝试 CrawlerProcess 但因为我使用不同的蜘蛛。我决定使用 CrawlerRunner。在第一次爬行之后一切都很好,但第二个过程给了我这个错误。

twisted.internet.error.ReactorNotRestartable

我尝试了这个主题的解决方案: ReactorNotRestartable error in while loop with scrapy

所以我尝试以下代码的解决方案,但爬虫永远不会停止,它说ReactorAlreadyRunning

def test():
    configure_logging({'LOG_FORMAT': '%(levelname)s: %(message)s'})
    runner = CrawlerRunner(get_project_settings())
    d = runner.crawl(myspider.My_Spider)
    d.addBoth(lambda _: reactor.stop(stop_after_crawl=False))
    reactor.run()

这不是让我爬另一只蜘蛛。那么如何在我的网站上在不同时间运行爬取多个蜘蛛呢?

【问题讨论】:

    标签: python scrapy


    【解决方案1】:

    这个话题帮助我解决问题。我只需要安装 crochet 并在我的代码之上添加 setup()

    Solution link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-12
      • 1970-01-01
      • 2017-05-21
      • 1970-01-01
      相关资源
      最近更新 更多