diff options
Diffstat (limited to 'weather.py')
| -rw-r--r-- | weather.py | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -24,11 +24,15 @@ class weather_met_no(weather): # constant for api request when getting data # uses Norweigen Meterological Institute api # -- todo : reference - self.CALL = "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat={}&lon={}".format( - self.LOCATION[0], self.LOCATION[1] + self.CALL = ( + "https://api.met.no/weatherapi/locationforecast/" + + "2.0/compact?lat={}&lon={}".format( + self.LOCATION[0], self.LOCATION[1] + ) ) # acceptable header for the API - # https://stackoverflow.com/questions/10606133/sending-user-agent-using-requests-library-in-python + # https://stackoverflow.com/questions/10606133/ + # sending-user-agent-using-requests-library-in-python # https://api.met.no/doc/FAQ self.HEADERS = {"User-Agent": "TopologicalMap"} super.init(self) @@ -36,9 +40,9 @@ class weather_met_no(weather): def get_temperature(self): # https://docs.python-requests.org/en/latest/ try: - data = requests.get(self.CALL, headers=self.HEADERS).json()["properties"][ - "timeseries" - ][0]["data"] + data = requests.get( + self.CALL, headers=self.HEADERS + ).json()["properties"]["timeseries"][0]["data"] return data["instant"]["details"]["air_temperature"] # data['next_1_hours']['summary']['symbol_code'] except: |
