wiseflow/client/backend/background_task.py

31 lines
561 B
Python
Raw Normal View History

2024-04-07 09:37:47 +08:00
"""
通过编辑这个脚本可以自定义需要的后台任务
"""
import schedule
import time
from work_process import ServiceProcesser
import configparser
config = configparser.ConfigParser()
2024-04-07 21:40:26 +08:00
config.read('../config.ini')
2024-04-07 09:37:47 +08:00
if config.has_section('sites'):
web_pages = config['sites']
urls = [value for key, value in web_pages.items()]
else:
urls = []
sp = ServiceProcesser()
2024-04-09 11:38:51 +08:00
2024-04-07 09:37:47 +08:00
def task():
sp(sites=urls)
# 每天凌晨1点运行任务
schedule.every().day.at("01:17").do(task)
while True:
schedule.run_pending()
time.sleep(60)