Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import requests
- import json
- url = "https://data.twojapogoda.pl/forecasts/themed/allergies/default/2333"
- r = requests.get(url)
- text_json = json.loads(r.text)
- allergens_dzis = text_json['forecasts']['default'][0]['allergens']
- allergens_noc = text_json['forecasts']['default'][1]['allergens']
- allergens_jutro = text_json['forecasts']['default'][2]['allergens']
- lista = ["Trawy",
- "Bylica",
- "Brzoza",
- "Alternaria",
- "Olsza",
- "Dąb",
- "Komosa",
- "Cladosporium",
- "Babka",
- "Szczaw",
- "Pokrzywa",
- "Leszczyna",
- "Wierzba",
- "Topola"]
- allerg_dict = {lista[i]:allergens_dzis[i] for i in range(len(lista))}
- json_object = json.dumps(allerg_dict)
- with open("/config/www/Pylenie/pylenie_today.json","w" ) as f:
- f.write(json_object)
- allerg_dict = {lista[i]:allergens_noc[i] for i in range(len(lista))}
- json_object = json.dumps(allerg_dict)
- with open("/config/www/Pylenie/pylenie_night.json","w" ) as f:
- f.write(json_object)
- allerg_dict = {lista[i]:allergens_jutro[i] for i in range(len(lista))}
- json_object = json.dumps(allerg_dict)
- with open("/config/www/Pylenie/pylenie_tomorrow.json","w" ) as f:
- f.write(json_object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement