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