Created
April 21, 2013 12:05
-
-
Save ryz310/5429375 to your computer and use it in GitHub Desktop.
MyJCBのサイトから過去6ヶ月分の確定請求額を取得するスクリプトです。httpsへのアクセスができずに悩んでいたのですが、httpsのページをgetする前に m.ssl_version = :SSLv3 を指定することで上手く行きました。
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' | |
require 'openssl' | |
# OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE | |
id = 'xxxxxxxx' | |
pass = 'xxxxxxxx' | |
top_page = 'https://my.jcb.co.jp/Login' | |
m = Mechanize.new | |
m.ssl_version = :SSLv3 | |
# toppage => login | |
m.get(top_page) | |
m.page.forms[0]['userId' ] = id | |
m.page.forms[0]['password'] = pass | |
m.page.forms[0].submit | |
# MyJCB top => ご利用明細 | |
m.get(m.page.search('a#_id218').first['href']) | |
# 確定月の詳細へのリンクを取得する | |
m.page.links_with(:text => /お振替分ご利用明細(確定分)/).each { |link| | |
# 確定月の表示 | |
print link.text.strip + ' ' | |
# 確定月の詳細ページへ移動 | |
m.get(link.href) | |
# "今回のお支払金額合計"を含む行を検索 | |
amount = m.page.search('div>table tr').find { |tr| | |
tr.children.find { |th| | |
th.name == 'th' && th.content =~ /今回のお支払金額合計/ | |
} | |
}.children[2] | |
# 支払い合計額の表示 | |
puts amount.content | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment