Created
October 9, 2011 18:54
-
-
Save kylegibson/1274018 to your computer and use it in GitHub Desktop.
PHP script to scrape data from a gist page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
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