Giter Club home page Giter Club logo

lloydstsb's Introduction

Lloyds TSB screen scraper

I bank with Lloyds TSB - I have my current account and credit card with them. Like most online banking services though, they're not to up-to-date on APIs and the like. After looking around online, I found that there were a couple of scripts that people had built, but I didn't have much luck with them myself. So I decided to build my own screen scraper.

I know the code in this is pretty messy, and as ever, it's untested. I tried to refactor it and got to the end, but then it turned out to be broken and I couldn't be bothered to fix it. So I've left it for now.

Usage

The file example.rb provides a very simple example of how the code works, but here's a step by step:

  1. Ensure the gem is installed, and then include it in your Ruby file, or in your Gemfile where appropriate:
$ gem install lloydstsb
`require 'lloydstsb'
  1. Create a hash with three symbol keys, :username, :password and :memorable_word, each unsurprisingly corresponding to different authentication details used
@settings = {
  username: "123456789",
  password: "a secure password",
  memorable_word: "banking"
}
  1. Instantiate a new instance of the LloydsTSB::Customer object, passing in the hash from the previous step - this is used to perform the authentication required.

customer = LloydsTSB::Customer.new(@settings)

  1. Call the accounts method of the object you just made - it'll take a few seconds, and will return a number of LloydsTSB::Account objects. Play with the response as you wish.
puts customer.name
customer.accounts
customer.accounts.first.transactions

Data models

A LloydsTSB::Customer is created with LloydsTSB::Customer.new with a hash of settings passed in. It has the following attributes:

  • agent (Mechanize::Agent) - the Mechanize agent used to browse around the online banking system. This will be pointing at the "Your accounts" page.
  • name (string) - the name of the customer
  • accounts (array) - an array of LloydsTSB::Account objects representing accounts held by the customer

A LloydsTSB::Account instance has the following attributes:

  • name (string) - the name of the account
  • balance (integer) - the balance of the account, whether positive or negative. *(NB: The true meaning of balance is affected by whether the account is a :credit_card or a :bank_account)
  • limit (integer) - the credit limit for the account - this is an overdraft limit for a current account, or the spending limit on a credit card
  • transactions (array) - an array containing a number of LloydsTSB::Transaction object - this will be the 20(?) most recent transactions on the account
  • details (hash)__ - the identifying information for the account as a hash. For a bank account, this will have keys :account_number and :sort_code, with :card_number for credit cards
  • type (symbol) - the type of the account, either :credit_card or :bank_account

A LloydsTSB::Account has many LloydsTSB::Transaction instances in its transactions property. Each transaction has the following attributes:

  • date (Date) - the date of the transaction as shown on the statement
  • narrative (string) - a description of the transaction, most likely the name of the merchant
  • type (symbol) - the type of transaction, usually an acronym - a list is available on the Lloyds TSB site
  • direction (symbol) - either :credit or :debit, depending on what the transaction is
  • amount (integer) - The amount of the transaction, obviously...
  • unique_reference (string)_ - a hash to identify this transaction (fairly) uniquely...useful if you want to see whether a transaction is new or not

Limitations

  • I haven't tested this with savings account, so it may well mess the script up and cause exceptions. I'll need to open a savings account to test this.
  • It will only show a limited number of transactions - it doesn't navigate through the different pages

License

Use this for what you will, as long as it isn't evil. If you make any changes or cool improvements, please let me know at [email protected].

lloydstsb's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.