Finance-Bank-HSBC

 view release on metacpan or  search on metacpan

HSBC.pm  view on Meta::CPAN

        $token = $stream->get_tag("td");
        
        if ($token->[1]{height} eq "25") {
            # We have an account.
            my $accountname = $stream->get_trimmed_text("/td");
            $stream->get_tag("td");

            my $accounttype = $stream->get_trimmed_text("/td");
            $stream->get_tag("td");

            my $accountnumber = $stream->get_trimmed_text("/td");
            $stream->get_tag("td");
            $stream->get_tag("td");

            my $accountbalance = $stream->get_trimmed_text("/td");

            # Convert / [CD]$/ to a positive or negative float.
            $accountbalance =~ s/ C$//;
            $accountbalance = "-$accountbalance" if $accountbalance =~ s/ D$//;
                   
            push @accounts, {
                balance    => $accountbalance,
                name       => $accountname,
                type       => $accounttype,
                account    => $accountnumber
            };
        }
    }
    return @accounts;
}

1;
__END__
# Below is stub documentation for your module. You better edit it!

=head1 NAME

Finance::Bank::HSBC - Check your HSBC bank accounts from Perl

=head1 SYNOPSIS

  use Finance::Bank::HSBC;
  my @accounts = Finance::Bank::HSBC->check_balance(
      bankingid   => "IBxxxxxxxxxx",
      seccode     => "xxxxxx",
      dateofbirth => "ddmmyy"
  );

  foreach (@accounts) {
      printf "%25s : %13s / %18s : GBP %8.2f\n",
        $_->{name}, $_->{type}, $_->{account}, $_->{balance};
  }

=head1 DESCRIPTION

This module provides a rudimentary interface to the HSBC online
banking system at C<https://www.ebank.hsbc.co.uk/>. 

=head1 DEPENDENCIES

You will need either C<Crypt::SSLeay> or C<IO::Socket::SSL> installed 
for HTTPS support to work with LWP.  This module also depends on 
C<WWW::Mechanize> and C<HTML::TokeParser> for screen-scraping.

=head1 CLASS METHODS

    check_balance(bankingid => $u, seccode => $p, dateofbirth => $d)

Return an array of account hashes, one for each of your bank accounts.

=head1 ACCOUNT HASH KEYS 

    $ac->name
    $ac->type
    $ac->account
    $ac->balance
 
Return the account owner's name, account type (eg. 'STUDENT A/C'), account
number, and balance as a signed floating point value.

=head1 WARNING

This warning is from Simon Cozens' C<Finance::Bank::LloydsTSB>, and seems
just as apt here.

This is code for B<online banking>, and that means B<your money>, and
that means B<BE CAREFUL>. You are encouraged, nay, expected, to audit
the source of this module yourself to reassure yourself that I am not
doing anything untoward with your banking data. This software is useful
to me, but is provided under B<NO GUARANTEE>, explicit or implied.

=head1 THANKS

Simon Cozens for C<Finance::Bank::LloydsTSB>, upon which most of this code
is based, Andy Lester (and Skud, by continuation) for WWW::Mechanize, Gisle
Aas for HTML::TokeParser, Leon Cowle for updated login code after HSBC
changed their HTML.

=head1 AUTHOR

Chris Ball C<chris@cpan.org>

=cut



( run in 0.795 second using v1.01-cache-2.11-cpan-6aa56a78535 )