Page 1 of 1

php scrapping

Posted: Thu Nov 18, 2010 3:35 pm
by mchohan
Hi,
I'm trying to get html from an external site using the below code. The issue I have is that sometimes it returns nothing and it doesn't even error, nor is the ERR_NO or ERR set. Im i missing something or is there a setting incorrect from the below?:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);

$result['EXE'] = curl_exec($ch);
$result['INF'] = curl_getinfo($ch);
$result['ERR'] = curl_error($ch);
$result['ERR_NO'] = curl_errno($ch);

curl_close($ch);
return $result;