Telefonní systém kosmické lodi Hipporion ze SKSP2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
796 B

#!/usr/bin/python3
import xml.etree.ElementTree as ET
from datetime import datetime as dt
from urllib import request
xml = request.urlopen('https://www.yr.no/place/Czech_Republic/Olomouc/Ruda_nad_Moravou/forecast.xml').read()
root = ET.fromstring(xml)
days = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']
for time in root.iter('time'):
attrib = time.attrib
time_from = dt.strptime(attrib['from'], '%Y-%m-%dT%H:%M:%S')
time_to = dt.strptime(attrib['to'], '%Y-%m-%dT%H:%M:%S')
style = time.find('symbol').attrib
temperature = time.find('temperature').attrib
preci = time.find('precipitation')
output = days[time_from.weekday()] + time_from.strftime(' %H') + '-' + time_to.strftime("%Hh") + ': ' + temperature['value'] + '°C' + ', ' + style['name']
print(output.replace('Partly', 'Pt.'))