二十六、Scrapy自定义命令
创建命令目录及文件
settings.py中定义命令
代码
from scrapy.commands import ScrapyCommand??class 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()
相关推荐
andrewwf 2020-11-11
Arvinzx 2020-10-28
CycloneKid 2020-10-27
paleyellow 2020-10-25
baifanwudi 2020-10-25
heyboz 2020-10-21
wumxiaozhu 2020-10-16
zhangll00 2020-07-05
javaraylu 2020-06-28
ZHANGRENXIANG00 2020-06-28
Catastrophe 2020-06-26
Catastrophe 2020-06-26
fangjack 2020-06-25
andrewwf 2020-06-16
qyf 2020-06-14
荒乱的没日没夜 2020-06-14
MiracleZhao 2020-06-13