Closed KT197 closed 1 year ago
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')
对原文件进行了修改,但是无法实现定时刷新,不知道是方法不对,还是代码错误了
你可以使用第三方工具定时执行程序。
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.
请问怎样添加下方代码,实现定时功能。
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')