-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitparser.py
More file actions
39 lines (25 loc) · 891 Bytes
/
Copy pathgitparser.py
File metadata and controls
39 lines (25 loc) · 891 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
29
30
31
32
33
34
35
36
37
38
39
import time
from os import getenv
from dotenv import find_dotenv, load_dotenv
from service import GitHubAPIService
from user_service import UserCRUDService
load_dotenv(find_dotenv())
def user_parser():
last_user_id = UserCRUDService.get_last_user_id()
while True:
request = GitHubAPIService.get_users_from_API(last_user_id)
if request.status_code != 200:
print(request.text)
return None
users = request.json()
if not users:
return None
for user in users:
if user["login"].count("z") > 2:
print(user["login"])
UserCRUDService.create_user(user)
last_user_id = users[-1]["id"]
# Otherwise you get banned because of ratelimit of your token
time.sleep(3600 / int(getenv("RATELIMIT")))
if __name__ == "__main__":
user_parser()