如何从一个网站获得文本并显示在另一个 [英] How to get text from one website and display on another

查看:97
本文介绍了如何从一个网站获得文本并显示在另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待code脚本,但我想知道我将如何让我们说从一个网站获得的数据(site1.com - 比方说在网页中只包含文本,例如:ABC123),我想另一个网站要能如果可能抢到一个PHP的格式,没有了iframe或任何此数据(site2.com)。

I am looking to code scripts, but I would like to know how would I let's say get data from one website (site1.com - let's say the page contains ONLY text, IE: abc123) and I want another website to be able to grab this data (site2.com) in a PHP format, no iframes or anything, if possible.

我会如何做这样?我想code API脚本一样,所以人们可以将其添加到他们的网站,并没有什么,例如;字符串发生器(site1.com将生成字符串,site2.com将能够使用的字符串中的PHP格式)

How would I go about doing such? I want to code API like scripts, so people can add them to their site and what not, for example; string generator (site1.com will generate the string, and site2.com will be able to use the string in a php format)

和我想学习的方式是一样的上面,还有一个办法,其中site2.com可以选择返回值的长度。像site1.com将设置明显的恢复,让我们说,如果想站点2 5数字组成的字符串,SITE1将生成字符串,只需在页面返回它(site1.com/gen?leng=5可以工作,但它的事得到它的网站上显示。)

And the way I would like to learn is the same as above, AND also a way where site2.com can choose the length of the returned value. Like site1.com will be setup obviously to return let's say if site2 wanted a string of 5 digits, site1 will generate the string and simply return it in the page (site1.com/gen?leng=5 could work, but its the matter of getting it displayed on the site..)

我想站点1生成的字符串,每说。我想外部网站(站点2)能够获得这个字符串,并在PHP格式使用它,像$字符串= site1generatedstring

推荐答案

在第二个站点,您可以:

In second site you can:

$remoteText = file_get_html("http://firstserver.com/page");

和您可以处理这个VAR( $ remoteText ),因为你需要。

And you can handle this var ($remoteText) as you need.

这篇关于如何从一个网站获得文本并显示在另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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