开发者

getting the source code of a website dynamically with php [duplicate]

This question already has answers here: 开发者_StackOverflow Closed 11 years ago.

Possible Duplicate:

Best methods to parse HTML with PHP

I wish to get the code of a website as you can with "view source" but dynamically. I found a site which does exactly what i want - http://www.iwebtool.com but I wish to implement it by myself. any ideas? thanks!


You chould give this a try in a php page:

<html>
<head><title>title</title></head>
<body>
<xmp>
<?php echo file_get_contents('http://www.google.com'); ?>
</xmp>
</body>
</html>

You could replace 'http://www.google.com' with the value of a variable you can set dynamically.


<xmp> is deprecated also you should take care of html special chars so I'd go with:

<pre>
    <?php echo htmlentities( file_get_contents( 'http://www.somewebsite.com/somepage.html' ) ); ?>
</pre>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜