Skip to content

Instantly share code, notes, and snippets.

@jrtashjian
Created April 4, 2011 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrtashjian/902156 to your computer and use it in GitHub Desktop.
Save jrtashjian/902156 to your computer and use it in GitHub Desktop.
<?php
function fetch( $url )
{
print "Crawling : $url\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
print "Complete : ".$info['url']."\n";
print "HTTP Code : ".$info['http_code']."\n";
print "Request Time : ".$info['total_time']."\n";
print "\n--\n\n";
//cleanup
$ch = $info = NULL;
unset($ch, $info);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment