19 lines
440 B
Python
19 lines
440 B
Python
|
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()
|