I am writing a php script to grab information from more than 30 different links currently.
Say I have an array storing all the links, and then use a foreach loop to pass the link to a function grabDataFromLink($url)
But turns out it can at most grab 10 to 15 links’ data, and then it stopped giving data anymore. Why is it so?
My code is something like this:
function grabDataFromLink($link){
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$content = curl_exec($ch);
echo $content;
curl_close($ch);
}
foreach ($links as $key => $link)
grabDataFromLink($link);
Check the php error log, check if a time limit or memory limit occurred. Is so, put set_time_limit(0);ini_set(memory_limit, -1); at the beginning of your script.
(answered by xdazz)