Last active
January 9, 2016 17:34
-
-
Save brodul/5f7adac520c98c803cf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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