在Firebase中定期将python程序作为后台服务运行 [英] Periodically run a python program as a background service in firebase

查看:40
本文介绍了在Firebase中定期将python程序作为后台服务运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需开始使用Firebase +反应构建一个网站.我网站的设计功能之一是抓取并向用户显示从另一个网站解析的数据(例如,股价变化).我已经有一个python搜寻器负责解析数据,但是我不知道如何在firebase中执行服务器的python搜寻器(在后台)(或者甚至不可能)?

Just start using the firebase + react to build a website. One of the designed features of my website is to crawl and show users the data parsed from another website (e.g., the stock price changes). I already have a python crawler responsible to parse the data, but I have no idea how to execute this python crawler (in the background) of my server in firebase (or it is not even possible)?

这是我系统的示例用法

  1. 用户登录并订阅他们感兴趣的网站/数据
  2. 我的抓取工具将每1小时解析一次该网站,并将数据更新到数据库中
  3. 用户可以从数据库中查看网站的变更摘要

我想到的一个选项是在本地计算机上运行搜寻器,并使用REST API将已解析的数据更新为firebase数据库.但是,这似乎是一种非常低效/幼稚的方法,因为它失去了使用Firebase等云服务部署服务器的意义.

One option I have in mind is running the crawler in my local machine and use the REST api to update the parsed data to firebase database. However, it seems a very inefficient/naive approach because it is kind of losing the meaning of deploying my server with cloud service, like firebase.

推荐答案

Firebase没有任何服务/功能可让您定期运行Python或任何其他代码.最接近的是Cloud Functions,可以通过cron-job.org之类的外部服务来触发.

Firebase does not have any service/feature that allows you to periodically run Python or any other code. The closest thing to that is Cloud Functions, which can be triggered through an external service like cron-job.org.

有关更多信息,请参见:

For more in this, see:

  • Firebase Hosting Flask Application (on running Python on Firebase Hosting)
  • Using google cloud function to spawn a python script (for an elaborate way where you might apparently run Python on Cloud Functions, but I never have, nor am likely to ever try this myself)
  • Cloud Functions for Firebase trigger on time? (for running Cloud Functions periodically either through AppEngine, or cron-job.org).

这篇关于在Firebase中定期将python程序作为后台服务运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆