php scrapping

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mchohan
Forum Newbie
Posts: 2
Joined: Fri Aug 20, 2010 8:35 am

php scrapping

Post 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;
Post Reply