关键词

爬虫 开启定时任务

1、导入模块

import datetime
import time

 

2、代码

def time_task():
    while True:
        now = datetime.datetime.now()
        # print(now.hour, now.minute)
        if now.hour == 0 and now.minute == 0:
            start_spider()
        if now.hour == 6 and now.minute == 0:
            break
        # 每隔60秒检测一次
        time.sleep(60)

 

本文链接:http://task.lmcjl.com/news/6705.html

展开阅读全文