Search code examples
phpfiledownloadcopytranslucency

Save website sourecode to file via php


Hi I wan to save the sourecode of http://stats.pingdom.com/w984f0uw0rey to some directory in my website

<?php
if(!copy("http://stats.pingdom.com/w984f0uw0rey", "stats.html"))
{
echo("failed to copy file");
}
;
?>

but this does not work either for me:

<?php
$homepage = file_get_contents('http://stats.pingdom.com/w984f0uw0rey');
echo $homepage;
?>

But I cannot figure how to do it!

thanks


Solution

  • use

    <?
    
    file_put_contents('w984f0uw0rey.html', file_get_contents('http://stats.pingdom.com/w984f0uw0rey'));
    
    ?>
    

    be sure that the script has write privileges to the current directory