-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfetch.py
53 lines (43 loc) · 1.82 KB
/
fetch.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import requests
import json
def fetch_repos():
url = "https://api.github.com/users/antoniopelusi/repos"
response = requests.get(url)
if response.status_code == 200:
repos = response.json()
filtered_repos = []
for repo in repos:
# Endpoint per ottenere i linguaggi della repository
languages_url = repo["languages_url"]
languages_response = requests.get(languages_url)
# Controlla se la richiesta per i linguaggi è andata a buon fine
if languages_response.status_code == 200:
languages = languages_response.json()
else:
languages = {}
# Creazione dell'oggetto filtro
filtered_repo = {
"created_at": repo["created_at"],
"name": repo["name"],
"html_url": repo["html_url"],
"languages": list(languages.keys()) # Solo i nomi dei linguaggi
}
filtered_repos.append(filtered_repo)
# Salva i risultati in un file JSON
final_json = json.dumps(filtered_repos, indent=4)
with open('assets/data/repos.json', 'w') as json_file:
json_file.write(final_json)
print("Repos: ready")
else:
print(f"Errore: Impossibile ottenere le repository (status code: {response.status_code})")
def fetch_cv():
url = "https://drive.google.com/uc?export=download&id=1gO0xD8AMeXDzXfcd_xIzL01kG7lrVOGj"
response = requests.get(url)
if response.status_code == 200:
with open("assets/data/cv.pdf", "wb") as file:
file.write(response.content)
print("CV: ready")
else:
print(f"Errore: Impossibile scaricare il CV (status code: {response.status_code})")
fetch_repos()
fetch_cv()