Permalink
Browse files

Changes to keep up with the Schwab site

  • Loading branch information...
1 parent 53adf0e commit af0bf2fa46c17816d5d9fc89669182640060a5e5 @mvgrimes committed Jul 23, 2010
Showing with 35 additions and 18 deletions.
  1. +4 −0 Changes
  2. +6 −7 README
  3. +25 −11 lib/Finance/Bank/Schwab.pm
View
@@ -1,5 +1,9 @@
Changes for Finance::Bank::Schwab
+1.20 - Fri Jul 23 10:10:39 EDT 2010
+ Updated the login form/post routine to accommodate the new Schwab login
+ procedures.
+
1.19 - Thu Apr 8 16:30:30 2010
Strip ALL of the footnotes out of the table fields
View
13 README
@@ -12,12 +12,11 @@ SYNOPSIS
printf "%20s : %8s / %8s : USD %9.2f\n",
$_->name, $_->sort_code, $_->account_no, $_->balance;
}
-
+
DESCRIPTION
- This module provides a rudimentary interface to the Charles Schwab site
- at `https://investing.schwab.com/trading/start'. You will need either
- `Crypt::SSLeay' or `IO::Socket::SSL' installed for HTTPS support to
- work. `WWW::Mechanize' is required.
+ This module provides a rudimentary interface to the Charles Schwab site.
+ You will need either "Crypt::SSLeay" or "IO::Socket::SSL" installed for
+ HTTPS support to work. "WWW::Mechanize" is required.
CLASS METHODS
check_balance()
@@ -39,7 +38,7 @@ OBJECT METHODS
Return the account balance as a signed floating point value.
WARNING
- This warning is verbatim from Simon Cozens' `Finance::Bank::LloydsTSB',
+ This warning is verbatim from Simon Cozens' "Finance::Bank::LloydsTSB",
and certainly applies to this module as well.
This is code for online banking, and that means your money, and that
@@ -49,7 +48,7 @@ WARNING
but is provided under NO GUARANTEE, explicit or implied.
THANKS
- Simon Cozens for `Finance::Bank::LloydsTSB'. The interface to this
+ Simon Cozens for "Finance::Bank::LloydsTSB". The interface to this
module, some code and the pod were all taken from Simon's module.
AUTHOR
View
@@ -21,14 +21,20 @@ use Carp;
use WWW::Mechanize;
use HTML::TableExtract;
-our $VERSION = '1.19';
+our $VERSION = '1.20';
our $ua = WWW::Mechanize->new(
env_proxy => 1,
keep_alive => 1,
timeout => 30,
+ cookie_jar => {},
);
+# Debug logging:
+# $ua->default_header( 'Accept-Encoding' => scalar HTTP::Message::decodable() );
+# $ua->add_handler( "request_send", sub { shift->dump; return } );
+# $ua->add_handler( "response_done", sub { shift->dump; return } );
+
sub check_balance {
my ( $class, %opts ) = @_;
my $content;
@@ -47,15 +53,23 @@ sub check_balance {
my $self = bless {%opts}, $class;
- $ua->get("https://investing.schwab.com/trading/start")
+ # Get the login page
+ $ua->get(
+ 'https://client.schwab.com/Login/SignOn/CustomerCenterLogin.aspx')
or croak "couldn't load inital page";
- $ua->submit_form(
- form_name => 'SignonForm',
- fields => {
- 'SignonAccountNumber' => $opts{username},
- 'SignonPassword' => $opts{password},
- },
- ) or croak "couldn't sign on to account";
+
+ # Find the login form, change the action url, then set the username/
+ # password and submit
+ my $login_form = $ua->form_name('aspnetForm')
+ or croak "Couldn't find the login form";
+ $login_form->action(
+ 'https://client.schwab.com/Login/SignOn/signon.ashx')
+ or croak "Couldn't update the action url on login form";
+ my $username_field =
+ 'ctl00$WebPartManager1$CenterLogin$LoginUserControlId$txtLoginID';
+ $login_form->value( $username_field => $opts{username} );
+ $login_form->value( 'txtPassword' => $opts{password} );
+ $ua->submit() or croak "couldn't sign on to account";
$content = $ua->content;
}
@@ -77,6 +91,7 @@ sub check_balance {
);
{
+
# HTML::TableExtract warns about undef value with keep_html option
$SIG{__WARN__} = sub {
warn @_ unless $_[0] =~ /uninitialized value in subroutine entry/;
@@ -155,8 +170,7 @@ Finance::Bank::Schwab - Check your Charles Schwab accounts from Perl
=head1 DESCRIPTION
-This module provides a rudimentary interface to the Charles Schwab site
-at C<https://investing.schwab.com/trading/start>.
+This module provides a rudimentary interface to the Charles Schwab site.
You will need either C<Crypt::SSLeay> or C<IO::Socket::SSL> installed
for HTTPS support to work. C<WWW::Mechanize> is required.

0 comments on commit af0bf2f

Please sign in to comment.