diff --git a/app/constants.py b/app/constants.py new file mode 100644 index 0000000..9d13124 --- /dev/null +++ b/app/constants.py @@ -0,0 +1,6 @@ +datasets = [ + "coronavirus-commercants-parisiens-livraison-a-domicile" + "deconfinement-pistes-cyclables-temporaires" + "deconfinement-paking-relais-doublement-des-places" +] +url = "https://opendata.paris.fr/api/v2/catalog/datasets/{}/exports/json?rows=-1&pretty=false&timezone=UTC" diff --git a/app/request_datasets.py b/app/request_datasets.py index 5875ffe..38e85d8 100644 --- a/app/request_datasets.py +++ b/app/request_datasets.py @@ -1,3 +1,4 @@ +from constants import datasets, url from requests import get from json import dump @@ -9,14 +10,12 @@ def save_json(data): def request_dataset(url): request = get(url) - response = request.json() - response.dump() + data = request.json() + save_json(data) def main(): - url = "https://opendata.paris.fr/api/v2/catalog/datasets/{}/exports/json?rows=-1&pretty=false&timezone=UTC".format( - "deconfinement-pistes-cyclables-temporaires" - ) + url.format("deconfinement-pistes-cyclables-temporaires") if __name__ == "__main__":