每隔X分钟点击给定的API并将结果推送到数据库中 [英] Hitting a given API every X minutes and pushing results into DB

查看:66
本文介绍了每隔X分钟点击给定的API并将结果推送到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候开发人员!

因此,我已经成为专业开发人员近3个月了,并且非常喜欢它.我主要使用C#ASP.NET,但对各种SQL实现和其他Web技术了解很多.这是我对大家的问题:

我想在服务器上运行脚本/程序(当前在InMotion Hosting上的服务器上有空间),该脚本/程序每10分钟触发一次,访问网站的API,然后将值推送到数据库中. br/>
我知道如何设置数据库以及如何将数据推入数据库.我不太了解的领域如下:

1.我将使用哪种语言编写该程序以及如何实现?

-我真的不知道从哪里开始.我获得了可执行文件,但没有获得如何使某些过程自动化并使其在没有用户交互的情况下运行的方法.

2.如何连接到给定的API并处理对其的调用?

-我了解如何解析XML,但是对于如何真正启动此过程我不太确定.我是否可以在自己的服务器上打开端口?我可以ping一些目标IP吗?我到底该怎么办?

可能会抛出任何其他提示和技巧,无论它们是对1还是2的回答,都将不胜感激.

在此先感谢所有.很高兴最终成为CodeProject的成员:)

Greetings fellow developers!

So I''ve been a professional developer for close to 3 months now and am thoroughly enjoying it. I work primarily with C# ASP.NET but know a good bit about various SQL implementations and other web technologies. Here is my question to you all:

I would like to run a script/program on a server (I currently have space on a server at InMotion Hosting) that fires off every 10 minutes, hits a web site''s API, and then pushes the values into a database.

I know how to set up the database and how to push things into it. The areas of this that I don''t quite understand are as follows:

1. What language would I write this program in and how would I implement it?

-I really don''t know where to even start with this. I get executables, but I do not get how to automate some process and have it run without user interaction.

2. How to connect to a given API and process calls to it?

-I understand how to parse out XML but I''m not too certain on how to actually initiate this process. Do I open up a port on my own server? Do I ping some target IP? What exactly do I do?

Any other tips and tricks that could be thrown my way would be greatly appreciated, regardless if they are in answer to either 1 or 2.

Thanks in advance all. Glad to finally be a member of CodeProject :)

推荐答案

如果您需要在这样的系统级别运行的进程,则应该研究创建Windows服务来做到这一点为你. Windows服务可以在后台运行,并执行您想要的操作.
If you need a process to run at a system level like this you should investigate creating a windows service to do this for you. The windows service can run in the background and do what you want it to.


在unix/linux上,您可以使用cron: http://en.wikipedia.org/wiki/Task_Scheduler [ ^ ]安排可以执行的任何操作.

问候
Espen Harlinn
On unix/linux you use cron: http://aplawrence.com/BDD/bbcronbasics.html[^]

On windows you create a service as Marcus suggested - or use the windows task scheduler http://en.wikipedia.org/wiki/Task_Scheduler[^] to schedule anything that can be executed.

Regards
Espen Harlinn


您需要找出Web api提供的协议.语言不会有问题.大多数语言都支持REST,SOAP,XML-RPC.

简单的方法遍历API文档.在那里,您可能会找到示例编码.
You need to find out what protocols the web api offers. Language will not be a problem. Most of the languages support REST, SOAP, XML-RPC.

Easy way go through the API documentation. There you might find example codings.


这篇关于每隔X分钟点击给定的API并将结果推送到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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