Skip to content

Instantly share code, notes, and snippets.

@lirenlin
Created July 5, 2013 18:56
Show Gist options
  • Save lirenlin/5936512 to your computer and use it in GitHub Desktop.
Save lirenlin/5936512 to your computer and use it in GitHub Desktop.
simple script to get the gist of somebody
#!/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