scrapy顺序执行多个爬虫

来源:互联网 发布:淘宝网如何盈利模式 编辑:程序博客网 时间:2024/05/17 22:58
爬虫的时候写了一个main.py,里面使用下面代码:
import sysimport osfrom scrapy.cmdline import executesys.path.append(os.path.dirname(os.path.abspath(__file__)))execute(["scrapy", "crawl", "shanghaione"])time.sleep(30)sys.path.append(os.path.dirname(os.path.abspath(__file__)))execute(["scrapy", "crawl", "shanghaitwo"])

本来以为可以运行,但是执行完第一句爬虫就停了。

于是有了我找到了新方法:

import sysimport osimport timefrom scrapy.cmdline import executeimport osos.system("scrapy crawl shanghaione")time.sleep(300)os.system("scrapy crawl shanghaitwo")
这样一来就可以了


原创粉丝点击