|
| 1 | +import requests |
| 2 | +from pprint import pprint |
| 3 | + |
| 4 | +# github username |
| 5 | +username = "x4nth055" |
| 6 | +# url to request |
| 7 | +url = f"https://api.github.com/users/{username}" |
| 8 | +# make the request and return the json |
| 9 | +user_data = requests.get(url).json() |
| 10 | +# pretty print JSON data |
| 11 | +pprint(user_data) |
| 12 | +# get name |
| 13 | +name = user_data["name"] |
| 14 | +# get blog url if there is |
| 15 | +blog = user_data["blog"] |
| 16 | +# extract location |
| 17 | +location = user_data["location"] |
| 18 | +# get email address that is publicly available |
| 19 | +email = user_data["email"] |
| 20 | +# number of public repositories |
| 21 | +public_repos = user_data["public_repos"] |
| 22 | +# get number of public gists |
| 23 | +public_gists = user_data["public_gists"] |
| 24 | +# number of followers |
| 25 | +followers = user_data["followers"] |
| 26 | +# number of following |
| 27 | +following = user_data["following"] |
| 28 | +# date of account creation |
| 29 | +date_created = user_data["created_at"] |
| 30 | +# date of account last update |
| 31 | +date_updated = user_data["updated_at"] |
| 32 | +# urls |
| 33 | +followers_url = user_data["followers_url"] |
| 34 | +following_url = user_data["following_url"] |
| 35 | + |
| 36 | +# print all |
| 37 | +print("User:", username) |
| 38 | +print("Name:", name) |
| 39 | +print("Blog:", blog) |
| 40 | +print("Location:", location) |
| 41 | +print("Email:", email) |
| 42 | +print("Total Public repositories:", public_repos) |
| 43 | +print("Total Public Gists:", public_gists) |
| 44 | +print("Total followers:", followers) |
| 45 | +print("Total following:", following) |
| 46 | +print("Date Created:", date_created) |
| 47 | +print("Date Updated:", date_updated) |
| 48 | + |
0 commit comments