如何在整整一周 - 晚上轻松,便宜地每5分钟即可轻松运行一个简单的Python脚本?

发布于 2025-02-08 14:14:46 字数 313 浏览 1 评论 0原文

我想运行一个非常简单的Python脚本(或任何语言),该脚本(或任何语言)以常规的5分钟间隔从API收集数据并保存数据。我需要这个过程才能持续整整一周 - 黑夜。我不能整个星期都保留笔记本电脑,所以我想我需要在某种服务器上运行。

我做这样的事情的最便宜,最简单的方法是什么? 这是一个非常简单的脚本,因此我不想花费大量时间来设置复杂的服务器,这最终对于这样的任务而言是过分的。

伪代码:

# Every 5 minutes for a whole week:

data = call_api(url)
write_csv(data)

I want to run a very simple python script (or any language) which collects data from an api at regular 5 minute intervals and saves the data. I need this process to run for a whole week - day and night. I can't keep my laptop on all week so I guess I will need this to run on some kind of server.

What is the cheapest and easiest way for me to do something like this?
This is an incredibly simple script so I don't want to spend ages setting up a complicated server which is ultimately overkill for a task like this.

Pseudocode:

# Every 5 minutes for a whole week:

data = call_api(url)
write_csv(data)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2025-02-15 14:14:46

您将需要云服务器,因为如果您无法在家设置系统,这是最便宜的选择。我将第二furas对pythonanywhere.com的评价。我使用他们的每月5美元计划来运行这样的简单任务。您可以随时取消,因此,如果仅1周,则您为帐户支付5美元,仅此而已。

也没有设置的混乱,只需上传您的main.py并作为仪表板中的任务作为任务即可。

You're going to need a cloud server as it's the cheapest option if u can't setup a system at home. I'll 2nd what furas said about pythonanywhere.com. I use their $5 a month plan to run simple tasks like this. You can cancel anytime so if it's just 1 week then you pay $5 for your account, that's it.

There is no messing around with setup either, just upload your main.py and schedule as task in the dashboard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文