Created
December 4, 2014 15:00
-
-
Save mfriedenberg/12d620d67f16ff935bee 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 urllib2 | |
import json | |
key = "[your API key]" | |
while 1: | |
zip = raw_input('For which ZIP code would you like to see the weather forecast? ') | |
url = 'http://api.wunderground.com/api/' + key + '/geolookup/forecast10day/q/' + zip + '.json' | |
f = urllib2.urlopen(url) | |
json_string = f.read() | |
parsed_json = json.loads(json_string) | |
for day in parsed_json['forecast']['simpleforecast']['forecastday']: | |
print day['date']['weekday'] + ' (' + day['date']['pretty'] + '):' | |
print ' Conditions: ' + day['conditions'] | |
print ' High:' + day['high']['fahrenheit'] + 'F' | |
print ' Low: ' + day['low']['fahrenheit'] + 'F' | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment