It's still not beautiful, though. area is hokkaido (within the jurisdiction of Hokkaido Electric Power Company) tohoku (under the jurisdiction of Tohoku Electric Power) tokyo (within the jurisdiction of TEPCO) chubu (within the jurisdiction of Chubu Electric Power) kansai (Kansai Electric Power jurisdiction) kyushu (Kyushu Electric Power jurisdiction You can change the acquisition area with.
denryoku.py
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import requests
import json,urllib2
import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
url = "http://setsuden.yahooapis.jp/v1/Setsuden/latestPowerUsage?"
appid = "appid=**************************************************"
output = "&output=json"
area = "&area=tokyo"
req_seq = url + appid + output + area
r = requests.get(req_seq)
res = r.json()
for i in res:
print json.dumps(res, sort_keys = True, indent = 4)
Recommended Posts