Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Automatic Bank Balance Checking at WaMu

I bank at Washington Mutual, and I wanted to see when I was spending too much, or get automated updates of what I was spending money on each day and what my balance was. However, it's really difficult to do and WaMu won't let you use an API or something helpful like that, so I wrote my own little screen-scraper to do it.

This requires WWW::Mechanize, but it works quite well.

require 'rubygems'
require 'mechanize'

agent = WWW::Mechanize.new

# login to the account
puts "Login"
page = agent.get('https://online.wamu.com/IdentityManagement/Logon.aspx')
login_form = page.forms.with.name("frmLogin").first
login_form.txtUserID = '<UNAME>'
login_form.password = '<PWD>'
page = agent.submit(login_form, login_form.buttons.first)

# click on the download button
puts "Download"
dl_link = page.links.with.text(/WAMU FREE CHECKING/)
page = agent.click(dl_link)

line_items = []

trs = (page/"table#_ctl0_depositTransactionsGrid/tr")
trs.shift
trs.each do |tr|
  tds = (tr/:td)

  dtd = tds[1].inner_html
  js_call = dtd.match(/showDDATransactionDetails\('(.*)'\);/)[1]
  js_fields = js_call.split("','")

  item = {}
  item['type'] = js_fields[1]
  item['descr'] = js_fields[3]
  item['amount'] = js_fields[4]
  item['tranid'] = js_fields[6]
  # if !tranid = ovedraft charge / bank fee

  item['date'] = tds[0].inner_html
  item['debit'] = tds[3].inner_html
  item['credit'] = tds[4].inner_html
  item['balance'] = tds[5].inner_html

  line_items << item
end

pp line_items.first


« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS