download doc files

Discussion in 'PHP' started by ssimon171078, Jul 1, 2015.

  1. #1
    i wrote php script ,how can i download all doc files from this script ,filenames of files is named filename:
    <?php
    $filename="log.txt";
    $content=file_get_contents("https://www.google.co.il/search?q=web+developer+resume+%2Bdoc&oq=web+developer+resume+%2Bdoc&gs_l=serp.3...2230.4053.0.4373.3.3.0.0.0.0.138.363.0j3.3.0....0...1c.1.64.serp..1.2.238.MfTYR8_YLe4");
    $dom=new DOMDocument;
        $dom->loadhtml($content);
          $links=$dom->getElementsByTagName("a");
        foreach ($links as $link)
    {
        $resume=$link->getAttribute("href");
       
         if (strpos($resume,"url?q=") ) {
           
            $start=strpos($resume,"url?q=");
            $stop=strpos($resume,".doc");
             $filename=substr($resume,$start+6,$stop-$start-2);
           
           
        }
    
        }
    
    
    
    
    
    ?>
    PHP:

     
    ssimon171078, Jul 1, 2015 IP