-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbad_srp.py
More file actions
29 lines (21 loc) · 866 Bytes
/
bad_srp.py
File metadata and controls
29 lines (21 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
import json
class ListRepositories():
API_BASE_URL = "https://api.github.com"
def __init__(self, user):
self.user = user
def get_repos_by_user(self):
response = requests.get(f'{self.API_BASE_URL}/users/{self.user}/repos')
if response.status_code == 200:
return {"status_code":200, "body": response.json()}
else:
return {"status_code":response.status_code, "body": "Erro"}
def parse_response(self):
response = self.get_repos_by_user()
body = response["body"]
if response["status_code"] == 200:
for i in range(len(body)):
print(f'{body[i]["id"]}\t- {body[i]["name"]} | {body[i]["stargazers_count"]}')
repos = ListRepositories("rafaelcamarda")
responde = repos.get_repos_by_user()
responseParse = repos.parse_response()