Reputation: 73
I use file_get_html to simple html DOM but i cant figure out how to get page source of a url! Is there any way? im not talking about paintext !
Thanks
Upvotes: 0
Views: 797
Reputation: 6182
try file_get_contents
. It will fetch the source of a website url
if you want to see the source code try this
echo htmlentities(file_get_contents("http://www.google.com"));
http://php.net/manual/en/function.file-get-contents.php
You can do this using CURL also
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com");
$result = curl_exec($ch);
curl_close($ch);
Upvotes: 4