| import xml.etree.ElementTree as ET | |
| import StringIO | |
| from najdisi_sms import SMSSender | |
| import requests | |
| sms = SMSSender('brodul', 'nom') | |
| file_obj = StringIO.StringIO( | |
| requests.get(( | |
| 'http://meteo.arso.gov.si/uploads/' | |
| 'probase/www/fproduct/text/sl/fcast_SI_OSREDNJESLOVENSKA_latest.xml' | |
| )).text.encode('utf-8') | |
| ) | |
| tree = ET.parse(file_obj) | |
| root = tree.getroot() | |
| message = [] | |
| for day in root.findall('metData'): | |
| dayname = day.find('valid_day').text.split()[0] | |
| daypart = day.find('valid_daypart').text | |
| forecast = day.find('nn_shortText').text | |
| rain = day.find('wwsyn_shortText').text or '' | |
| message.append("%s %s - %s %s" % (dayname, daypart, forecast, rain.upper()) ) | |
| sms.send('031123456' ,'\n'.join(message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment