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

方案(一)name.py

#!/usr/bin/env python

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

# -*- 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来运行此文件即可

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄