Get Weather using JSON web service and Python

Get the current weather for Copenhagen:

import urllib2
import json

# hent vejret for Koebenhavn
url = 'http://api.openweathermap.org/data/2.5/weather?q=Copenhagen,dk'
response = urllib2.urlopen(url)

# parse JSON resultatet
data = json.load(response)
print 'Weather in Copenhagen:', data['weather'][0]['description']

Comments

One response to “Get Weather using JSON web service and Python”

  1. […] Nie za bardzo wiedziałam jak mam się do tego zabrać, więc zajrzałam do podobnych kodów: kilk, kilk, klik, klik. Oczywiście wszystkie przykłady oparte są na Pythonie 2 i niestety nie sprawdzałam […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.