#! /usr/bin/env perl ## ---------------------------------------------------------------------------- ## "THE BEER-WARE LICENSE" (Revision 42): ## wrote this file. As long as you retain this notice you ## can do whatever you want with this stuff. If we meet some day, and you think ## this stuff is worth it, you can buy me a beer in return. Florent Thoumie ## ---------------------------------------------------------------------------- ## ## This is teh config part. ## my $acct_num = ""; # This is the Open24 number my $acct_passwd = ""; # This is the Internet password my $acct_pac = ""; # This is the Personal Access Code (6 digits) ## ## Don't modify anything after this line unless you know what you're doing. ## use strict; use warnings; use WWW::Mechanize; use HTML::TokeParser; my $agent; my $stream; my $tag; my ($digita, $digitb, $digitc); my $version = "0.1"; $agent = WWW::Mechanize->new(); ## ## First login page (open24 number + internet password). ## $agent->get("https://www.open24.ie/online/login.aspx"); $agent->submit_form( form_name => 'frmLogin1', fields => { txtLogin => $acct_num, txtPassword => $acct_passwd, __EVENTTARGET => "lbtnContinue", __EVENTARGUMENT => "" }, ); ## ## Second login page (personal access code). ## $stream = HTML::TokeParser->new(\$agent->{content}); $stream->get_tag("table"); $stream->get_tag("table"); $tag = $stream->get_tag("span"); $digita = $stream->get_trimmed_text("/span"); $digita =~ s/.*(.)$/$1/; $digita = substr($acct_pac, $digita-1, 1); $tag = $stream->get_tag("span"); $digitb = $stream->get_trimmed_text("/span"); $digitb =~ s/.*(.)$/$1/; $digitb = substr($acct_pac, $digitb-1, 1); $tag = $stream->get_tag("span"); $digitc = $stream->get_trimmed_text("/span"); $digitc =~ s/.*(.)$/$1/; $digitc = substr($acct_pac, $digitc-1, 1); $agent->submit_form( form_name => 'frm2', fields => { txtDigitA => $digita, txtDigitB => $digitb, txtDigitC => $digitc, __EVENTTARGET => "btnContinue", __EVENTARGUMENT => "" }, ); ## ## Account summary ## my ($name, $balance, $avail); my @header = ("Account name", "Balance", "Available"); my @sep = ("--------------------------------", "-------------", "-------------"); format ACCOUNT = | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | @>>>>>>>>>>> | @>>>>>>>>>> | $name, $balance, $avail . $stream = HTML::TokeParser->new(\$agent->{content}); $stream->get_tag("table"); $stream->get_tag("table"); $stream->get_tag("table"); $stream->get_tag("td"); $~ = "ACCOUNT"; ($name, $balance, $avail) = @sep; write; ($name, $balance, $avail) = @header; write; ($name, $balance, $avail) = @sep; write; while (1) { $stream->get_tag("td"); $name = $stream->get_trimmed_text("/td"); last if ($name =~ /\xa0/); $stream->get_tag("td"); $stream->get_tag("td"); $balance = $stream->get_trimmed_text("/td"); $stream->get_tag("td"); $avail = $stream->get_trimmed_text("/td"); write; } ($name, $balance, $avail) = @sep; write; $~ = "STDOUT";