Created
June 3, 2017 12:16
-
-
Save smbatyan1729/0cc239adea3e8e74bd5693dd1208fb03 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 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