WezM.net Menu

Scraping NAB Internet Banking with Mechanize

Published on Sat, 18 July 2009

This week I wanted to write a script that would get my account balances from nab Internet Banking. These types of things are generally quite simple with Ruby and Mechanize. I got the basics of the script up and running fairly quickly but when I ran it the site always rejected my username and password.

After a lot more time in the Safari Web Inspector I finally worked out that the site actually expects the password submitted to the login page to be ‘mixed’ with a key that is unique for each page load. The ‘mixing’ (for lack of a better description) is performed by a javascript function. After I reimplemented this function in my Ruby script I was then able to sucessfully login and retrieve my account balances. My code is supplied below for anyone else who is wanting to do something like this.

Comment icon Something to Add?

Contact me by email or Twitter if you have a comment, correction or just want to get in touch.