get account balances from bank Web site?

Franco Saliola saliola-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Mon Aug 8 00:55:03 UTC 2005


On 8/3/05, Aaron Vegh <aaronvegh-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
> Hi Franco,
> Thanks very much for this very informative script. I'm not very good
> with perl (more a PHP guy, so I'm not completely lost!), so this
> really helped.
> 
> However, due to my ignorance I have not been able to finish this
> script, so I was hoping for a little expertise to push me the final
> few steps.
> 
> I have five accounts that I would like to get the balances of, and
> have written a loop that goes through the source code of the site
> using HTML::TokeParser. The code looks like this:
> 
> my $stream = HTML::TokeParser->new(\$mech->{content});
> while ($stream->get_tag("a")) {
>         if (rindex($stream->get_trimmed_text("/a"), $savingsacct) > 0) {
>                 $stream->get_tag("td"); $stream->get_tag("td"); $stream->get_tag("td");
>                 print "Savings Account: " . $stream->get_trimmed_text("/td") . "\n";
>         }
>         elsif (rindex($stream->get_trimmed_text("/a"), $chequingacct) > 0) {
>                 $stream->get_tag("/td"); $stream->get_tag("/td"); $stream->get_tag("td");
>                 print "Chequing Account: " .  $stream->get_trimmed_text("/td") . "\n";
>         }
>         elsif (rindex($stream->get_trimmed_text("/a"), $dreamacct) > 0) {
>                 $stream->get_tag("/td"); $stream->get_tag("/td"); $stream->get_tag("td");
>                 print "Dream Account: " .  $stream->get_trimmed_text("/td") . "\n";
>         }
>         elsif (rindex($stream->get_trimmed_text("/a"), $caracct) > 0) {
>                 $stream->get_tag("/td"); $stream->get_tag("/td"); $stream->get_tag("td");
>                 print "Car Account: " .  $stream->get_trimmed_text("/td") . "\n";
>         }
>         elsif (rindex($stream->get_trimmed_text("/a"), $locacct) > 0) {
>                 $stream->get_tag("/td"); $stream->get_tag("/td"); $stream->get_tag("td");
>                 print "Line of Credit: " . $stream->get_trimmed_text("/td") . "\n";
>         }
> }
> 
> The result is, the script outputs the balance for the first account in
> this loop ("Savings Account"), but nothing else. Am I doing something
> wrong? I've been banging my head against the wall on this one.

Hello Aaron,

The code that you have here looks fine, so I suspect the problem is
that the conditionals aren't satisfied except in the Savings Account
case. Try putting some print statements (print "I'm trying to grab the
Line of Credit balance...\n";) and see if the script actually enters
the various cases. Perhaps the rindex isn't set correctly. How are you
setting $dreamacct, etc.?

Franco

--
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list