Batch Downloading in PHP
<?php for($d=1;$d<=100;$d++) { $link=”http://www.domain.com/demos/”.$d.”/source.zip”; if(http_url_exists($link)) { echo”Processing: “.$link.”<br>”; exec(“wget -O “.dirname(__FILE__).”/download/source-“.$d.”.zip “.$link.” 2>&1″,$pp); echoimplode(“”,$pp);echo”<br><br>”; } } //$file_headers = @get_headers($file); //’HTTP/1.1 404 Not Found’ function url_exists($url){ if(!$fp=curl_init($url))returnfalse; returntrue; } function http_url_exists($url){ $file_headers=@get_headers($url); if($file_headers[0]==’HTTP/1.1 404 Not Found’) returnfalse; returntrue; } ?>