Webpage saver script

Discussion in 'PHP' started by digmod, Feb 7, 2008.

  1. #1
    Hi,

    I need a php script that could get a webpage address and save it as a file (html or else) on the server.

    Anyone can help?
     
    digmod, Feb 7, 2008 IP
  2. imvain2

    imvain2 Peon

    Messages:
    218
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you may want to go into more detail.

    like are you looking more a php script to download the html and save it, or are you looking for something to download the entire page , css, html, flash, images and everything?
     
    imvain2, Feb 7, 2008 IP
  3. Possibility

    Possibility Peon

    Messages:
    350
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How would the script get the webpage address? Would it be entered through a form? And like imvain2 said, do you want to save the webpage as a file or just write the URLs to a file?
     
    Possibility, Feb 7, 2008 IP
  4. digmod

    digmod Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No, only the html page, or say, the main page.

    I'd feed the script the web address and it should save the main page as a specific file, and if needed overwrite it. Because I'd want this script to run frequently over time, so it's annoying to assign a differnt file name or give permission to overwrite the same file each time.

    Thanks for your help.:)
     
    digmod, Feb 8, 2008 IP
  5. imvain2

    imvain2 Peon

    Messages:
    218
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    function SavePage($url,$filename){
     $xml = file_get_contents($url);
     $fp = fopen($filename,"w");
     fwrite($fp,$xml);
     fclose($fp);
    }
    
    PHP:
    Just pass the function the url and the full path for the file name:D
    Nice clean and simple
     
    imvain2, Feb 8, 2008 IP
  6. digmod

    digmod Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks imvain, that script was great!

    Now, how could i save the output file on another server through ftp? Is it Possible?

    Thanks again:)
     
    digmod, Feb 13, 2008 IP
  7. imvain2

    imvain2 Peon

    Messages:
    218
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You can use php to ftp files
     
    imvain2, Feb 13, 2008 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    nico_swd, Feb 13, 2008 IP