#!/usr/bin/python # encoding:utf-8 import urllib2, json, urllib # 2、历史空气质量指数查询 data = {} data["appkey"] = "your_appkey_here" data["city"] = "杭州" url_values = urllib.urlencode(data) url = "https://api.jisuapi.com/aqi/history" + "?" + url_values request = urllib2.Request(url) result = urllib2.urlopen(request) jsonarr = json.loads(result.read()) if jsonarr["status"] != u"0": print jsonarr["msg"] exit() result = jsonarr["result"] print result["cityid"],result["city"] for hour in result["hour"]: print hour["so2"],hour["so224"],hour["no2"],hour["no224"],hour["co"],hour["co24"],hour["o3"],hour["o38"],hour["o324"],hour["pm10"],hour["pm1024"],hour["pm2_5"],hour["pm2_524"],hour["iso2"],hour["ino2"],hour["ico"],hour["io3"],hour["io38"],hour["ipm10"],hour["ipm2_5"],hour["aqi"],hour["primarypollutant"],hour["quality"],hour["timepoint"],hour["color"] for day in result["day"]: print day["so2"],day["so224"],day["no2"],day["no224"],day["co"],day["co24"],day["o3"],day["o38"],day["o324"],day["pm10"],day["pm1024"],day["pm2_5"],day["pm2_524"],day["iso2"],day["ino2"],day["ico"],day["io3"],day["io38"],day["ipm10"],day["ipm2_5"],day["aqi"],day["primarypollutant"],day["quality"],day["date"],day["color"]