From 531671d78283c2e75448da4b441a49396ca3479f Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 21 May 2020 18:45:51 +0200 Subject: [PATCH] Implement dataset request draft --- .gitignore | 1 + app/dummy_request.py | 16 ---------------- app/request_datasets.py | 23 +++++++++++++++++++++++ 3 files changed, 24 insertions(+), 16 deletions(-) delete mode 100644 app/dummy_request.py create mode 100644 app/request_datasets.py diff --git a/.gitignore b/.gitignore index 7bb7d67..bfd8bda 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ app/__pycache__ +Design.org diff --git a/app/dummy_request.py b/app/dummy_request.py deleted file mode 100644 index 9e5e3cd..0000000 --- a/app/dummy_request.py +++ /dev/null @@ -1,16 +0,0 @@ -from requests import get - - -def dummy_request(url): - request = get(url) - print(request.text) - - -def main(): - dummy_request( - "https://opendata.paris.fr/api/records/1.0/search/?dataset=velib-disponibilite-en-temps-reel&q=&facet=name&facet=is_installed&facet=is_renting&facet=is_returning&facet=nom_arrondissement_communes" - ) - - -if __name__ == "__main__": - main() diff --git a/app/request_datasets.py b/app/request_datasets.py new file mode 100644 index 0000000..5875ffe --- /dev/null +++ b/app/request_datasets.py @@ -0,0 +1,23 @@ +from requests import get +from json import dump + + +def save_json(data): + with open("cycling-paths.json", "w") as f: + dump(data, f, ensure_ascii=False) + + +def request_dataset(url): + request = get(url) + response = request.json() + response.dump() + + +def main(): + url = "https://opendata.paris.fr/api/v2/catalog/datasets/{}/exports/json?rows=-1&pretty=false&timezone=UTC".format( + "deconfinement-pistes-cyclables-temporaires" + ) + + +if __name__ == "__main__": + main()