Advertisement
jarekmor

pylenie_python3d

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