早明浦ダムの貯水率をスクレイピング

qiita.com

d.hatena.ne.jp

from urllib.request import urlopen
from bs4 import BeautifulSoup

base = 'http://www1.river.go.jp'

resp = urlopen(base + '/cgi-bin/DspDamData.exe?ID=1368080700010&KIND=3').read()
temp = BeautifulSoup(resp, 'html5lib')

# IFRAMEのURLからデータ取得
html = urlopen(base + temp.iframe['src']).read()
soup = BeautifulSoup(html, 'html5lib')

for tr in soup.select('tr'):
    tds = [td.string.strip() for td in tr.select('td')]

    if tds[6] != '-':
        print('早明浦ダムの{} {}現在の貯水率は{}%です'.format(tds[0], tds[1], tds[6]))
        break

2017/01/07

年末ぐらいから貯水率が表示されていない。