如何在Php中获取网址的Html源代码 [英] How to get Html Source Code of A url in Php

查看:116
本文介绍了如何在Php中获取网址的Html源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示网址的html源代码,我怎么能得到它。



我需要像这样的原始HTML代码:

 <  !DOCTYPE     html     PUBLIC     -  // W3C // DTD     XHTML     1.0     Transitional // EN   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >  

< html xmlns = http://www.w3.org/1999/xhtml >
< head id = Head1 > < title >

< / title > < / head >
< body < span class =code -keyword>>





我用它:

 <?php   $ data  = file_get_contents(   http://www.lorempixel.com/,0); 
echo $ data ;
?>





但它没有获得来源代码,



感谢任何帮助!

解决方案

数据 = file_get_contents( http://www.lorempixel.com/,0);
echo


data ;
?>





但它没有获得来源代码,



任何帮助表示赞赏!


  

Hi , I need to display html source code of a url , how can i get it .

I need raw html code like this :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1"><title>

</title></head>
<body>



I used it :

<?php  $data = file_get_contents("http://www.lorempixel.com/",0);
echo $data;
?>



But It was not getting Source code ,

Any help is appreciated !

解决方案

data = file_get_contents("http://www.lorempixel.com/",0); echo


data; ?>



But It was not getting Source code ,

Any help is appreciated !



这篇关于如何在Php中获取网址的Html源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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