Created
September 15, 2012 14:47
-
-
Save pceccato/3728308 to your computer and use it in GitHub Desktop.
Calling wunderground weather api...
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 | |
# make sure you put your api key in the request string | |
def getWeatherFromWunderground(country, city): | |
request = 'http://api.wunderground.com/api/YOUR_API_KEY_HERE/geolookup/conditions/forecast/q/%s/%s.json' % (country, city) | |
f = urllib2.urlopen(request) | |
json_string = f.read() | |
f.close() | |
parsed_json = json.loads(json_string) | |
location = parsed_json['location']['city'] | |
# temp_c = parsed_json['current_observation']['temp_c'] | |
# weather = parsed_json['current_observation']['weather'] | |
# print "%s. Current temperature in %s is: %s degrees celcius" % (weather, location, temp_c ) | |
return parsed_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment