ModernOSWeather/src/parser.py

19 lines
440 B
Python
Raw Permalink Normal View History

2024-10-17 19:45:27 +03:00
import json
import urllib.request
def parse_weather() -> None:
current = {}
forecast = {}
data = {}
response = urllib.request.urlopen("http://127.0.0.1:7841", timeout=10).read()
data = json.loads(response)
for params in data["current"]:
value = data["current"][params]
unit = data["current_units"][params]
current[params] = str(value) + " " + str(unit)
print(current)
parse_weather()