如何实现多个爬虫循环顺序爬取

首先设置一个循环,接着为每一个爬虫设置一个定时器,让每一个爬虫爬虫一段时间,再运行下一个爬虫即可。具体代码如下,此处设置每一个爬虫运行3600秒

import os

while True:
    os.system("scrapy crawl xinhuanet -s CLOSESPIDER_TIMEOUT=3600")  # 新华网
    os.system("scrapy crawl money163 -s CLOSESPIDER_TIMEOUT=3600")  # 网易财经
    os.system("scrapy crawl ccstock -s CLOSESPIDER_TIMEOUT=3600")  # 证券日报
    os.system("scrapy crawl cs -s CLOSESPIDER_TIMEOUT=3600")  # 中证网
    os.system("scrapy crawl p5w -s CLOSESPIDER_TIMEOUT=3600")  # 全景网
    os.system("scrapy crawl ztcj -s CLOSESPIDER_TIMEOUT=3600")  # 智通财经
    os.system("scrapy crawl huanqiu_finance -s CLOSESPIDER_TIMEOUT=3600")  # 环球财经

  

原文地址:https://www.cnblogs.com/fh-fendou/p/10096123.html