getting the source code of a website dynamically with php [duplicate]
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>
精彩评论