Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wunderground API: Streamlined python 2.7 code using the requests package. Must register at and insert your personal key.
import requests
data = requests.get('').json()
location = data['location']['city']
temp_c = data['current_observation']['temp_c']
print "Current temperature in %s is: %s C" % (location, temp_c)
import requests
def get_precip(gooddate):
urlstart = ''
urlend = '/q/Switzerland/Zurich.json'
url = urlstart + str(gooddate) + urlend
data = requests.get(url).json()
for summary in data['history']['dailysummary']:
print ','.join((gooddate,summary['date']['year'],summary['date']['mon'],summary['date']['mday'],summary['precipm'], summary['maxtempm'], summary['meantempm'],summary['mintempm']))
if __name__ == "__main__":
from datetime import date
from dateutil.rrule import rrule, DAILY
a = date(2013, 1, 1)
b = date(2013, 12, 31)
for dt in rrule(DAILY, dtstart=a, until=b):

This comment has been minimized.

Copy link

KiranPrajapati345 commented Feb 15, 2017

It's very useful,I have using your code to get data, can you tell me if I want to data for month wise, not day wise ,then what I have to changes in your code?
for example: I want data for month wise,
year , month, average_high_temp , average_low_temp, precipitation , humadity...
2015 Jan 25 20 0 10 likewise....
can you please help for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.