Created
February 9, 2019 10:31
-
-
Save stuartabrown/718eaee2813c4296bed11cd290da1d49 to your computer and use it in GitHub Desktop.
yr.no xml parse
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 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