Skip to content

Instantly share code, notes, and snippets.

@smbatyan1729
Created June 3, 2017 12:16
Show Gist options
  • Save smbatyan1729/0cc239adea3e8e74bd5693dd1208fb03 to your computer and use it in GitHub Desktop.
Save smbatyan1729/0cc239adea3e8e74bd5693dd1208fb03 to your computer and use it in GitHub Desktop.
import json
import requests
repos_url = None
with open('myJson.json', 'w') as f:
BASE_API_URL = 'https://api.github.com/'
name = input('Please input github username:')
r = requests.get(BASE_API_URL + 'users/%s' % name)
json.dump(r.json(), f)
with open('myJson.json', 'r') as f:
user_obj = json.load(f)
repos_url = user_obj['repos_url']
print(repos_url)
if repos_url:
r = requests.get(repos_url)
arr = []
for elem in r.json():
req = requests.get(elem['languages_url'])
arr += list(req.json().keys())
arr = set(arr)
line = (" ").join(arr)
with open('textbook.txt', 'w') as f:
f.write(name + " knows " + line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment