Commit c6b72fc6 authored by Mattia Bondanza's avatar Mattia Bondanza
Browse files

Prints time and weather for Pisa in the next three days.

parents
import pycurl
import json
from StringIO import StringIO
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'api.openweathermap.org/data/2.5/forecast?q=pisa,it&APPID=c5ebd88f4494c472f3032e3426b6f0c6')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
body = buffer.getvalue()
parsed = json.loads(body)
for i in parsed["list"]:
print i["dt_txt"], " ", i["weather"][0]["description"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment