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

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

parents
Loading
Loading
Loading
Loading
+17
Changes for pycurltest.py: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
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"]