Created
August 24, 2014 10:20
-
-
Save chroju/6cfb9869b7733d362af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'rubygems' | |
require 'mechanize' | |
class SBIBank | |
attr_accessor :id, :password | |
def initialize(id, password) | |
@id = id | |
@password = password | |
end | |
SBI_URL = "https://www.netbk.co.jp/wpl/NBGate" | |
# ログイン処理 | |
def login | |
# ログインページ | |
@agent = Mechanize.new | |
page = @agent.get(SBI_URL) | |
f = page.form('LoginForm') | |
f.userName = id | |
f.loginPwdSet = password | |
page = f.submit | |
# 「重要なお知らせ」が表示された場合 | |
if page.title =~ /重要なお知らせ/ | |
f = page.forms[0] | |
page = f.submit | |
end | |
end | |
# 現在高取得 | |
def get_balance | |
page = @agent.page | |
page = page.link_with(:text => '口座情報').click | |
return page.search('//div[@class="tableb02Mr"]')[0].text | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment