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

About this user

Scott Chacon

« 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.

   1  
   2  require 'rubygems'
   3  require 'mechanize'
   4  
   5  agent = WWW::Mechanize.new
   6  
   7  # login to the account
   8  puts "Login"
   9  page = agent.get('https://online.wamu.com/IdentityManagement/Logon.aspx')
  10  login_form = page.forms.with.name("frmLogin").first
  11  login_form.txtUserID = '<UNAME>'
  12  login_form.password = '<PWD>'
  13  page = agent.submit(login_form, login_form.buttons.first)
  14  
  15  # click on the download button
  16  puts "Download"
  17  dl_link = page.links.with.text(/WAMU FREE CHECKING/)
  18  page = agent.click(dl_link)
  19  
  20  line_items = []
  21  
  22  trs = (page/"table#_ctl0_depositTransactionsGrid/tr")
  23  trs.shift
  24  trs.each do |tr|
  25    tds = (tr/:td)
  26  
  27    dtd = tds[1].inner_html
  28    js_call = dtd.match(/showDDATransactionDetails\('(.*)'\);/)[1]
  29    js_fields = js_call.split("','")
  30  
  31    item = {}
  32    item['type'] = js_fields[1]
  33    item['descr'] = js_fields[3]
  34    item['amount'] = js_fields[4]
  35    item['tranid'] = js_fields[6]
  36    # if !tranid = ovedraft charge / bank fee
  37  
  38    item['date'] = tds[0].inner_html
  39    item['debit'] = tds[3].inner_html
  40    item['credit'] = tds[4].inner_html
  41    item['balance'] = tds[5].inner_html
  42  
  43    line_items << item
  44  end
  45  
  46  pp line_items.first


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