Skip to content

Instantly share code, notes, and snippets.

@separation
Last active March 24, 2018 08:26
Show Gist options
  • Save separation/1435c7fca8ed356bddfa9aeca13bf928 to your computer and use it in GitHub Desktop.
Save separation/1435c7fca8ed356bddfa9aeca13bf928 to your computer and use it in GitHub Desktop.
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