weiboSpider icon indicating copy to clipboard operation
weiboSpider copied to clipboard

定时功能

Open KT197 opened this issue 3 years ago • 2 comments
trafficstars

请问怎样添加下方代码,实现定时功能。

def auto_spider(stop_time): schedule.every(1).minutes.do(main) while True: if datetime.datetime.now().strftime('%H:%M') <= stop_time: schedule.run_pending() time.sleep(60) else: break

if name == 'main': auto_spider('22:00')

KT197 avatar Sep 05 '22 11:09 KT197

import time import datetime import schedule

import os import sys

from absl import app sys.path.append(os.path.abspath(os.path.dirname(os.getcwd()))) from weibo_spider.spider import main as mn

def func(): app.run(mn)

def auto_spider(stop_time): schedule.every(1).minutes.do(func) while True: if datetime.datetime.now().strftime('%H:%M') <= stop_time: schedule.run_pending() time.sleep(600) else: break

if name == 'main': auto_spider('20:00')

对原文件进行了修改,但是无法实现定时刷新,不知道是方法不对,还是代码错误了

KT197 avatar Sep 06 '22 13:09 KT197

你可以使用第三方工具定时执行程序。

dataabc avatar Sep 08 '22 13:09 dataabc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 12 '22 05:11 stale[bot]