
1. 在项目文件夹中新建一个commands文件夹
2. 在command的文件夹中新建一个文件 crawlall.py
3.在crawlall.py 中写一个command类,该类继承 scrapy.commands
from scrapy.commands import Scrapycommandclass Command(Scrapycommand): requires_project = True def Syntax(self): return ‘[options]‘ def short_desc(self): return ‘Runs all of the spIDers‘ def run(self,args,opts): spIDer_List = self.crawler_process.spIDers.List() for name in spIDer_List: self.crawler_process.crawl(name,**opts.__dict__) self.crawler_process.start()总结
以上是内存溢出为你收集整理的Scrapy同时启动多个爬虫全部内容,希望文章能够帮你解决Scrapy同时启动多个爬虫所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)