Skip to content

Instantly share code, notes, and snippets.

@kylegibson
Created October 9, 2011 18:54
Show Gist options
  • Save kylegibson/1274018 to your computer and use it in GitHub Desktop.
Save kylegibson/1274018 to your computer and use it in GitHub Desktop.
PHP script to scrape data from a gist page
<?
function get_gist_url($id) {
$data = file_get_contents("https://gist.github.com/$id");
$pos1 = strpos($data, "/raw/$id");
$pos2 = strpos($data, "\"", $pos1);
$url = substr($data, $pos1, $pos2-$pos1);
return "https://gist.github.com$url";
}
$url = get_gist_url($_GET["id"]);
ob_start('ob_gzhandler');
echo file_get_contents($url);
echo "\n# $url\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment