PHP Curl脚本,每10分钟从远程服务器提取数据 [英] PHP Curl script to pull data from remote server every 10 minutes

查看:286
本文介绍了PHP Curl脚本,每10分钟从远程服务器提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个PHP脚本,从远程服务器拉取xml数据(文本和图像),并将其插入本地数据库。我需要每10分钟左右运行这个脚本(并覆盖我的数据库中的现有数据)...如果我没有得到服务器大约一分钟后的响应,我想请求中止,直到下一个10分钟后脚本运行的时间。任何人都可以请给我一些想法,如何我可以实现这一点或指向我的教程,解释它在一个简单的术语。



谢谢!

编辑:我正在寻找帮助的PHP脚本本身,不确定是否清楚在我的最初的帖子。

解决方案

您可以创建连接到远程服务器并提取数据,插入到数据库中,设置限制和异常的铣削curl脚本的运行。然后在crontab中创建一个条目,每10分钟运行一次此脚本。我有一个类似的设置运行我的一个网站,它从股票交易所获取数据,并更新本地缓存,另一个脚本有任务,消耗缓存,当需要时。


I'm trying to create a PHP script which pulls xml data (text and images) from a remote server and inserts it in a local database. I need to run this script every 10 minutes or so (and overwrite the existing data in my db)... if I don't get a response from the server after about a minute, I would like the request to abort until the next time the script runs 10 minutes later. Can anyone please either give me some idea as to how I can achieve this or point me to a tutorial that explains it in fairly simple terms?

Thanks!

EDIT: I'm looking for help with the PHP script itself, not sure that was clear in my initial post.

解决方案

You can create a run of the mill curl script that connects to a remote server and fetches data, inserts into your db, set limits and exceptions. Then create an entry in crontab to run this script every 10 minutes. I have a similar setup running for one of my website which fetches data from stock exchange and updates a local cache, another script has the task of consuming the cache as and when required.

这篇关于PHP Curl脚本,每10分钟从远程服务器提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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