I'm going insane trying to figure out what is the problem but I can't find it.
$proxies = loadProxies(5);
function getData($proxylist)
{
$rand_proxy = rand(0,count($proxylist)-1);
$url = 'http://www.stackoverflow.com'; //just for example
$agent = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.4 (KHTML, like Gecko) Chrome/4.0.233.0 Safari/532.4";
$referer = "http://www.google.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_PROXY, $proxylist[$rand_proxy]);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
}
getData($proxies);
It should fetch a random proxy IP from the array and then use it in cURL request. All data I'm getting is a blank page. In some cases, I get infinite page load with no results whatsoever. What is causing this and how do I fix this? Thanks.