Last active
March 24, 2018 08:26
-
-
Save separation/1435c7fca8ed356bddfa9aeca13bf928 to your computer and use it in GitHub Desktop.
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
import urllib.request | |
import json | |
def request_gists(username): | |
url = 'https://api.github.com/users/' + username + '/gists' | |
with urllib.request.urlopen(url) as response: | |
text = response.read() | |
for gist in json.loads(text): | |
for filename in gist['files']: | |
yield { 'filename': filename, 'html_url': gist['html_url'], 'description': gist['description'] } | |
if __name__ == "__main__": | |
username = input("Username: ") | |
password = input("Password: ") | |
with open('README.md', 'w') as fp: | |
fp.write('# UVA Online Judge\n\n' ) | |
for gist in request_gists(username=username): | |
if gist['filename'].find('uva') > -1: | |
fp.write('## ') | |
fp.write('[' + gist['filename'] + ']') | |
fp.write('(' + gist['html_url'] + ')\n\n') | |
fp.write(gist['description'] + '\n\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment