我从一个网页,每天早上更新,在不同的时间更新的数据,我想知道如何让脚本运行每10分钟左右,以检查网站是否已更新。我正在考虑使用cron,但我不太理解它。谢谢你的帮助。
发布于 2017-03-30 09:43:55
您尝试过使用APScheduler包吗?它使得调度任务变得相当简单。这是the documentation。
要完成计划任务,需要做的就是这些(对于一些基本的事情):
from apscheduler.schedulers.background import BackgroundScheduler
from pytz import utc
scheduler = BackgroundScheduler()
scheduler.configure(timezone=utc)
def print_hello():
print("Hello, this is a scheduled event!")
job = scheduler.add_job(print_hello, 'interval', minutes=1, max_instances=10)
scheduler.start()然而,请注意,当我第一次尝试使用这个库时,我有一个小错误,但是关于如何修复它的解释是here。
https://stackoverflow.com/questions/43106370
复制相似问题