码迷,mamicode.com
首页 > 其他好文 > 详细

celery 调用scrapy

时间:2019-09-20 18:58:18      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:ret   get   pytho   project   crawler   调用   process   环境   tutorial   

  我的环境: celery 3.1.25 python 3.6.9 window10

 

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

from celery_app import app
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from 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()

celery 调用scrapy

标签:ret   get   pytho   project   crawler   调用   process   环境   tutorial   

原文地址:https://www.cnblogs.com/WalkOnMars/p/11558560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!