Created
July 5, 2013 18:56
-
-
Save lirenlin/5936512 to your computer and use it in GitHub Desktop.
simple script to get the gist of somebody
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
#!/usr/bin/python | |
import urllib2 | |
import json | |
user = "lirenlin" | |
url = "https://api.github.com/users/%s/gists" | |
HTML_header = ''' <!DOCTYPE html> | |
<html> | |
<head> | |
<title>Gist from Li Renlin</title> | |
</head> | |
''' | |
HTML_end = "</html>" | |
gist_js = "<script src=\"%s.js\"></script>\n" | |
page = open("page.html", 'w') | |
page.write(HTML_header) | |
user_url = urllib2.urlopen(url%user) | |
json_string = user_url.read() | |
parsed_json = json.loads(json_string) | |
for gist in parsed_json: | |
gist_url = gist["url"] | |
gist_html = gist["html_url"] | |
page.write(gist_js%gist_html) | |
page.write(HTML_end) | |
page.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment