Using python + sched + server Push Notification sauce realization timing.

Simple implementation a bit functionality, practical then have to continue to improve, can be added to the configuration file, continue to use the sched repeated reminders can be achieved.

After you have time, try to make a tool, this being the first. . .

#coding=utf-8
#这里需要引入三个模块
import time, sched import requests def doTask(): url = 'https://sc.ftqq.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.send' body = {"text": "哈哈哈,python推送测试", "desp": "测试文本"} response = requests.post(url, data = body) print(response.text) # doTask() # 第一个参数确定任务的时间,返回从某个特定的时间到现在经历的秒数  # 第二个参数以某种人为的方式衡量时间  schedule = sched.scheduler(time.time, time.sleep) def timming_exe(cmd, inc = 60): # enter用来安排某事件的发生时间,从现在起第n秒开始启动  schedule.enter(inc, 0, doTask) # 持续运行,直到计划时间队列变成空为止  schedule.run() print("ready to excute scrapt...") t = time.time() after = '2018-03-31 19:41:00' tm = time.mktime(time.strptime(after, '%Y-%m-%d %H:%M:%S')) timming_exe("doTask", int(tm - t))

Guess you like

Origin www.cnblogs.com/pzgspm/p/12008914.html