File size: 1,473 Bytes
6236000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import requests
from datetime import *

def get_final_type(types):
    type_mapping = {
        "Subvention": 2,
        "Prêt": 1,
        "Avance récupérable": 1,
        "Certificat d'économie d'énergie (CEE)": 4,
        "Autre aide financière": 4,
        "Ingénierie technique": 4,
        "Ingénierie financière": 4,
        "Ingénierie Juridique / administrative": 4
    }

    final_type_mapping = {
        1: "Avance − Prêts − Garanties",
        2: "Subvention",
        3: "Prise en charge des coûts et allègement des charges",
        4: "Autres"
    }

    for t in types:
        if t in type_mapping:
            return final_type_mapping[type_mapping[t]]

    return None  # Return None if no matching type is found


def request():
    subventions = requests.get('https://api.groupecegara.fr/aidesliste').json()
    return subventions

aides = request()
print(f"Nb aides : {len(aides)}")

for aide in aides:
    aide["metadata"] = {
        "type_aide": "Subvention",
        "lien": f"https://www.groupecegara.fr/publications-flash.html",
        "Source": f"https://www.groupecegara.fr/publications-flash.html"
    }


# print(subventions)
# week_number = datetime.today().isocalendar()[1]
# filename = 'cegara_sub_' + str(week_number)
# with open('{}.json'.format(filename), 'w', encoding='utf-8') as f:
with open('data/cegara_sub.json', 'w', encoding='utf-8') as f:
      json.dump(aides, f, ensure_ascii=False, indent=4)