Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created April 3, 2012 15:47
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 jonathantneal/2293056 to your computer and use it in GitHub Desktop.
Save jonathantneal/2293056 to your computer and use it in GitHub Desktop.
Curling caniuse
<?php
$referer = 'http://caniuse.com/index.php';
$url = 'http://caniuse.com/jsonp.php';
$user_agent = 'Mozilla/5.0 (compatible; Linux) Curl/1.0';
$file = 'data.json';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
curl_setopt($curl_handle, CURLOPT_REFERER, $referer);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_USERAGENT, $user_agent);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (!empty($buffer)) {
file_put_contents($file, $current);
} else {
exit(new Exception('No buffer returned.'));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment