iFrame的File_get_contents? [英] File_get_contents of an iFrame?

查看:86
本文介绍了iFrame的File_get_contents?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个外部网站的iframe,它有自动生成的html。



我想要做的是使用file_get_contents来获取在iFrame中的html,它存放在我的域名上。



所以这样的事情:



< pre lang =PHP> < iframe src = othersite.com > < / iframe < span class =code-keyword>>
<? php
$ contents = file_get_contents( // iFrame Content);
?>



I我希望有人指出我正确的方向。

解决方案

内容 = file_get_contents( // iFrame内容);
?>



我希望有人指出我正确的方向。


您需要向http://othersite.com发送HTTP请求,从中接收HTTP响应然后处理收到的数据。要使用HTTP,请从此处开始: http://www.php.net/manual/en/class .httprequest.php [ ^ ]。



-SA


好朋友,



我已经使用file_get_contents()将我的远程服务器上的index.php文件加载到我的localhost上,结果显示它只会获取帮助你只显示所有内容如果网页的所有引用绝对相当。



ie如果您尝试通过file_get_contents()加载的网页的样式表链接为

 <   link     rel   =  stylesheet   类型  =  text / css     href   =  ./ stylesheets / global.css    /  >  



然后,您将无法正确显示页面,可能需要进一步处理您加载的页面数据以某种方式使所有相对l墨水到绝对链接。



所以,如果你加载的网页有所有绝对链接,比如

 <   link     rel   =  stylesheet   类型  =  text / css     href   =  http://example.com/stylesheet/global.css    /  >  
< script type = text / javascript src = http://example.com/javascript/global。 jquery.js / >



然后,页面将正确显示而不会有任何中断...



希望它帮助你。标记为已解决,如果它确实:)



有问候

Tushar Srivastva


Basically I have an iframe of an external site, which has html that is auto-generated.

What I want to do is to use file_get_contents to get the html within that iFrame, which is hosted on my domain.

So something like this:

<iframe src="othersite.com"></iframe>
<?php
$contents = file_get_contents(//iFrame Content);
?>


I would love someone to point me into the right direction.

解决方案

contents = file_get_contents(//iFrame Content); ?>


I would love someone to point me into the right direction.


You need to send an HTTP request to http://othersite.com, receive HTTP response from it and then deal with received data. To do it with HTTP, start here: http://www.php.net/manual/en/class.httprequest.php[^].

—SA


Alright friend,

I have used file_get_contents() to load my index.php file on my remote server onto my localhost and what I get as a result reveals that it will only fetch help you to display all the contents properly only if the webpage's all references are made absolutely rather relatively.

i.e. If the webpage you are trying to load via file_get_contents () has a stylesheet linked as

<link rel="stylesheet" type="text/css" href="./stylesheets/global.css" />


Then, you will have no luck displaying the page properly and probably you have to further process the page data loaded by you to somehow make all relative links to absolute links.

So, if the webpage you are loading has all absolute links like

<link rel="stylesheet" type="text/css" href="http://example.com/stylesheet/global.css" />
<script type="text/javascript" src="http://example.com/javascript/global.jquery.js" />


Then, the page will display correctly without any break...

Hope that it helped you. Mark as solved if it did :)

With Regards
Tushar Srivastva


这篇关于iFrame的File_get_contents?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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