LoginSignup
7
8

More than 5 years have passed since last update.

Yahoo提供の電力使用状況APIで遊ぶ

Posted at

相変わらず美しくはないですが。
area は
hokkaido(北海道電力管轄内)
tohoku(東北電力管轄内)
tokyo(東京電力管轄内)
chubu(中部電力管轄内)
kansai(関西電力管轄内)
kyushu(九州電力管轄内
で取得エリアを変更できます。

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)
7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8