From 10458482f3d91f9d55ed536f4c7d6c5ea6d68cb6 Mon Sep 17 00:00:00 2001 From: Magne Furuholmen Myhren Date: Wed, 21 Jun 2023 09:05:25 +0200 Subject: [PATCH] =?UTF-8?q?Et=20lite=20script=20for=20=C3=A5=20kontakte=20?= =?UTF-8?q?brreg-API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- experimental/brreg_api_test.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 experimental/brreg_api_test.py diff --git a/experimental/brreg_api_test.py b/experimental/brreg_api_test.py new file mode 100644 index 0000000..c7f4bcb --- /dev/null +++ b/experimental/brreg_api_test.py @@ -0,0 +1,29 @@ +# + +import requests +HEADERS = { + + "Accept": 'application/json', + +} + +BASE_URL = "https://data.brreg.no/enhetsregisteret/api/" +def get_json(url, params={}): + + url = BASE_URL + url + req = requests.Request("GET", url=url, headers=HEADERS, params=params) + + #print(req.url, req.headers, req.params) + print("Full URL, check during testing:", req.prepare().url) + + response = requests.Session().send(req.prepare()) + + response.raise_for_status() + + # print(response.text) + return response.json() + +get_json("enheter")["_embedded"] + +# - + +