是否可以在PHP中读取另一个网页? [英] Is it possible to read another web page in PHP?

查看:65
本文介绍了是否可以在PHP中读取另一个网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以用PHP读取另一个网页?

如果是ASP.NET,代码将是

---------- -

WebRequest req = WebRequest.Create(" http://www.microsoft.com");

WebResponse res = req.GetResponse();

StreamReader sr = new StreamReader(res.GetResponseStream());

String Output = sr.ReadToEnd();

Response.Write("内容是:+输出;

--------


请告诉我这段代码的PHP等价物?谢谢。

Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output=sr.ReadToEnd();
Response.Write("The content is : " + Output);
--------

Would you please tell me the PHP equivalant of this code? Thank you.

推荐答案

我想如果你去 http://www.php.net/documentation


您会发现在文档中有一整个部分

致力于Filesystem。您可以找到许多不同的功能

有用:例如。 fread,fopep和更多。

ty ******* @ gmail.com 写道:
是否可以在PHP中读取另一个网页?
如果是ASP.NET,代码将是
--------- ---
WebRequest req = WebRequest.Create(" http://www.microsoft.com");
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader (res.GetResponseStream());
String Output = sr.ReadToEnd();
Response.Write(内容为:" +输出);
----- ---

请您告诉我这段代码的PHP等价物?谢谢。
Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output=sr.ReadToEnd();
Response.Write("The content is : " + Output);
--------

Would you please tell me the PHP equivalant of this code? Thank you.



我试图阅读的网页不在同一台服务器上。 fopen

也能为此工作吗?我可以用fopen阅读 www.microsoft.com 吗?


Ramon写道:
The web page I''m trying to read is not on the same server. Does fopen
also work for this? Can I read www.microsoft.com with fopen?

Ramon wrote:
我想如果你去 http: //www.php.net/documentation

您会发现在文档中有一整个专门用于Filesystem的部分。您可以找到许多不同的功能,例如: fread,fopep和更多。

ty ******* @ gmail.com 写道:
是否可以在PHP中读取另一个网页?
如果是ASP.NET,代码将是
--------- ---
WebRequest req = WebRequest.Create(" http://www.microsoft.com");
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader (res.GetResponseStream());
String Output = sr.ReadToEnd();
Response.Write(内容为:" +输出);
----- ---

请您告诉我这段代码的PHP等价物?谢谢。
Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output=sr.ReadToEnd();
Response.Write("The content is : " + Output);
--------

Would you please tell me the PHP equivalant of this code? Thank you.






道歉,我很想念。


但是fopen应该仍然有效:* fopen - 打开文件或URL *


阅读fopen文档条目。


ty ******* @ gmail.com 写道:
My apologies, I missunderstood.

But fopen should still work: *fopen -- Opens file or URL*

Have a read of the fopen documentation entry.


ty*******@gmail.com wrote:
网页我是试图读取不在同一台服务器上。 fopen
也能为此工作吗?我可以用fopen阅读 www.microsoft.com 吗?
拉蒙写道:
The web page I''m trying to read is not on the same server. Does fopen
also work for this? Can I read www.microsoft.com with fopen?

Ramon wrote:
我想如果你去 http: //www.php.net/documentation

您会发现在文档中有一整个专门用于Filesystem的部分。您可以找到许多不同的功能,例如: fread,fopep和更多。

ty*******@gmail.com写道:
I think if you go to http://www.php.net/documentation

You will find that in the documentation there is an entire section
dedicated to Filesystem. With many different functions that you may find
useful: eg. fread, fopep anbd many more.

ty*******@gmail.com wrote:
是否可以阅读另一个网页PHP?
如果是ASP.NET,代码将是
------------
WebRequest req = WebRequest.Create(" http:// www .microsoft.com");
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output = sr.ReadToEnd();
Response.Write(内容是:+输出);
--------

请您告诉我PHP的等价物码?谢谢。
Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output=sr.ReadToEnd();
Response.Write("The content is : " + Output);
--------

Would you please tell me the PHP equivalant of this code? Thank you.




这篇关于是否可以在PHP中读取另一个网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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