iKnow の進捗を Python で取得

iKnow の進捗を Python から取得できるようにしてみました。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import urllib
from BeautifulSoup import BeautifulSoup
import re

class Iknow:
    def __init__(self,username):

        b = BeautifulSoup(urllib.urlopen("http://www.iknow.co.jp/user/"+username))
        
        iknow = b.find('div',id="study_badge_div").find('script').string
        self.iknow_study = int(re.search(r"int_left.*?(\d+)", iknow).group(1))
        self.iknow_finish = int(re.search(r"int_right.*?(\d+)", iknow).group(1))

        dictation = b.find('div',id="dictation_badge_div").find('script').string
        self.dictation_study = int(re.search(r"int_left.*?(\d+)", dictation).group(1))
        self.dictation_finish = int(re.search(r"int_right.*?(\d+)", dictation).group(1))

if __name__ == '__main__':
    iknow = Iknow("yoshiori")
    print "yoshiori iKnow study : "+ str(iknow.iknow_study)
    print "yoshiori iKnow finish : " + str(iknow.iknow_finish)
    print "yoshiori dictation study : " + str(iknow.dictation_study)
    print "yoshiori dictation finish : " + str(iknow.dictation_finish)


BeautifulSoup が必要なので PyPi から持ってきてください><
はてなグラフとかに毎日書き込むようにしても良いかも♪

これで「数字よりグラフの方が見やすいんだよ!!」って言う人も
安心ですね♪


ni!