用脚本来运行scrapy crawl ...

启动爬虫的命令为: scrapy crawl spidername(爬虫名)

方案(一)name.py

#!/usr/bin/env python

# -*- coding:utf-8 -*-

from scrapy import cmdline

# 方式一:注意execute的参数类型为一个列表

cmdline.execute(‘scrapy crawl spidername‘.split())

# 方式二:注意execute的参数类型为一个列表

cmdline.execute([‘scrapy‘, ‘crawl‘, ‘spidername‘])

方案(二)name.py

import time
import os
while True:
  os.system("scrapy crawl sougou --nolog")
  time.sleep(30)# 30s设置定时的时间来执行

_________________________________________

通过python name.py来运行此文件即可

原文地址:https://www.cnblogs.com/qxh-beijing2016/p/10734518.html