From c36408ffe14e3bea477a807f3ab91ce0db6dce1c Mon Sep 17 00:00:00 2001 From: Milo Date: Fri, 5 Apr 2019 23:27:08 +0200 Subject: [PATCH] add aarhus-adak scraper --- server/nightr/scrape.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/nightr/scrape.py b/server/nightr/scrape.py index f985acb..b9c057f 100644 --- a/server/nightr/scrape.py +++ b/server/nightr/scrape.py @@ -3,6 +3,21 @@ import requests def scrape_traffic(): r = requests.get('https://portal.opendata.dk/api/3/action/datastore_search?resource_id=b3eeb0ff-c8a8-4824-99d6-e0a3747c8b0d') data = r.json() - print(data) + results = data['result']['records'] + -scrape_traffic() \ No newline at end of file +def scrape_dmi_aarhus(): + r = requests.get('https://www.dmi.dk/NinJo2DmiDk/ninjo2dmidk?cmd=obj&wmo=06074') + data = r.json() + latest_time, aarhus_latest_temp = max(data['Temperature2m'].items(), key= lambda x : x[0]) + + adak_r = requests.get('https://www.dmi.dk/NinJo2DmiDk/ninjo2dmidk?cmd=llj&id=5878818') + adak_data = adak_r.json() + adak_temp_latest = adak_data['timeserie'][0]['temp'] + if aarhus_latest_temp-5 < adak_temp_latest: + return 1.0 + return 0.0 + #adak_latest_time, adak_latest_temp_aarhus = max(adak_timeserie.items(), key= lambda x : x[0]) + + +scrape_dmi_aarhus() \ No newline at end of file