Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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