celery 调用scrapy

匿名 (未验证) 提交于 2019-12-03 00:09:02

  我的环境: celery 3.1.25 python 3.6.9 window10

 

celery tasks 代码如下,其中 QuotesSpider 是我的scrapy项目爬虫类名称

from celery_app import appfrom scrapy.crawler import CrawlerProcessfrom scrapy.utils.project import get_project_settingsfrom tutorial.spiders.quotes import QuotesSpider
def crawl_run():    scope = 'all'    process = CrawlerProcess(settings=get_project_settings())    process.crawl(QuotesSpider, scope)    process.start()    process.join()@app.task(queue='default')def execute_task():    return crawl_run()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!