Advertisement
jarekmor

pylenie_python

Mar 21st, 2023
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # pylenie.py
  3.  
  4. import requests
  5. import json
  6.  
  7. url = "https://data.twojapogoda.pl/forecasts/themed/allergies/daily/2333/1"
  8. r = requests.get(url)
  9. text_json = json.loads(r.text)
  10.  
  11. allergens = text_json["forecasts"][0]["allergens"]
  12. lista = ["Trawy",
  13. "Bylica",
  14. "Brzoza",
  15. "Alternaria",
  16. "Olsza",
  17. "Dąb",
  18. "Komosa",
  19. "Cladosporium",
  20. "Babka",
  21. "Szczaw",
  22. "Pokrzywa",
  23. "Leszczyna",
  24. "Wierzba",
  25. "Topola"]
  26.  
  27. allerg_dict = {lista[i]:allergens[i] for i in range(len(lista))}
  28. json_object = json.dumps(allerg_dict,ensure_ascii=False)
  29.  
  30. with open("pylenie.json","w" ) as f:
  31.     f.write(json_object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement