excel - How to skip unresponding url from list of urls in php -
i have list of urls in excel xheet. reading urls excel sheet , existing urls , non existing urls storing in serapare text files. problem if url not responding loop stopped. aim ship url , check next url.
require_once 'excel_reader2.php'; $data = new spreadsheet_excel_reader("urls.xls"); $totalsheets=count($data->sheets); for($i=0;$i<count($data->sheets);$i++) // loop sheets in file. { if(count($data->sheets[$i][cells])>0) // checking sheet not empty { $totalrows=count($data->sheets[$i][cells]); for($j=1;$j<=count($data->sheets[$i][cells]);$j++) // loop used each row of sheet { $name=$data->sheets[$i][cells][$j][1]; $url=$data->sheets[$i][cells][$j][2]; $file_headers =get_headers($url); if(strpos($file_headers[0],"200")==true || $file_headers[0]!= 'http/1.1 404 not found') { $exists = 'yes'; $myfile = fopen("existurls.txt", "w") or die("unable open file!"); $text .= $j." ".$name." ".$url."\n"; fwrite($myfile, $text); fclose($myfile); echo "url exists"; } else { $exists = 'no'; $myfile = fopen("nonexisturls.txt", "w") or die("unable open file!"); $text .= $j." ".$name." ".$url."\n"; fwrite($myfile, $text); fclose($myfile); echo "url not exists"; } } } }
the code working fine. if url not responding loop stopping , not going next one. please me how skip not responding url , continue loop.
Comments
Post a Comment