我有一个python脚本(对它进行处理selenium
并将结果发送到我的whatsapp [Used Twilio API]
),并将其托管在Heroku
&计划运行one time per day
。它按预期的时间表运行,但也可以按其他时间运行(每天运行6次以上)。除了预定的时间,我不想运行它。如何使它仅在计划的时间运行?
Procfile:
web: python my_script.py
除此之外,我requirements.txt & my_script.py
在目录中。
您可以使用time
模块和while
循环来检查当前时间是否等于所需时间。
from time import gmtime, strftime
desired_time = '13:28'
while True:
if strftime("%H:%M", gmtime()) == desired_time:
main()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句