Skip to content

Instantly share code, notes, and snippets.

@stuartabrown
Created February 9, 2019 10:31
Show Gist options
  • Save stuartabrown/718eaee2813c4296bed11cd290da1d49 to your computer and use it in GitHub Desktop.
Save stuartabrown/718eaee2813c4296bed11cd290da1d49 to your computer and use it in GitHub Desktop.
yr.no xml parse
import datetime
import untangle
data = untangle.parse('https://www.yr.no/place/Australia/Northern_Territory/Katherine/forecast.xml')
today = datetime.datetime.today()
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrowTemps = []
print ("today is " + today.strftime('%Y-%m-%d'))
print ("tomorrow is " + tomorrow.strftime('%Y-%m-%d'))
for forecast in data.weatherdata.forecast.tabular.time:
if (forecast['from'].replace('T', '-')[:-9] == tomorrow.strftime('%Y-%m-%d')):
tomorrowTemps.append(forecast.temperature['value'])
print (tomorrowTemps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment