I have been asked to write a script which will parse all href's in a page and then visit each href and check if each page is up and running ( using the HTTP code from CURL calls) . I have something like below :
<?php foreach($links_array as $link_array): //$links_array are a tags
$link_array=str_replace("'", "\"", $link_array); // if href='link' instead of href="link"
$href= get_attribute($link_array, "href");
$resolved_address= resolve_address($href, $page_base);
$download_href= http_get($resolved_address,$ref );
$url=$download_href['STATUS']['url'];
$http_code=$download_href['STATUS']['http_code'];
$total_time=$download_href['STATUS']['total_time'];
$message=$status_code_array[$download_href['STATUS']['http_code']];
// $status_code_array is an array
//if you refer to its index using the http code it give back the human
//readable message of the code
?>
<tr>
<td><?php echo $url ?></td>
<td><?php echo $http_code ?></td>
<td><?php echo $http_code ?></td>
<td><?php echo $total_time ?></td>
</tr>
<?php endforeach;?>
The script works for pages with small number of hrefs but if a page has many hrefs the script times out . I have tried increasing max_execution_time in php.ini but this doesnt seem to be an elegant solution . My questions are 1) How does production software works in these type of cases which takes a long time to execute . 2) Can I continue making CURL calls by catching the fatal "Maximum execution time of 60 seconds exceeded"error ? 3) Also it will be better if I can make a curl call for the first href , check for the code, print it using HTML and then make the next curl call for the second href , check for the code , print it and so forth . How can I do this ?
Please bare with my ignorance I am three months into web programming .
str_replace? This commentif href='link' instead of href="link"is incorrect, both quote types are valid.