我制作了一个网络抓取工具,可以跟踪购物网站的价格,并在有销售时通知用户。 我已经成功将其部署到Heroku,但是我希望我的flask应用程序每天检查价格。
我考虑过使用Heroku Scheduler,但是它需要一个命令行参数 到目前为止,基本上是我在仪表板POST路线中一直这样做的方式:
@app.route('/dashboard', methods=['POST'])
@login_required #cannot access directly must login first
def submission():
while(True):
if (check_price() == 0): # check_price() == 0 means that the price is under the budget and an email was sent
break # since the email was sent, we can exit the loop
time.sleep(43200) # keeps checking every 43200 seconds (12 hours) until the price falls below the budget
return redirect(url_for('index'))
,但这显然是不正确的,因为必须在浏览器中打开Web应用程序。 如何在Flask中使用Heroku Scheduler