/) {
warn "inside loop\n" if $debug;
@t = $stream->get_token;#get opening get_token;#get text between | | tags
warn "Right after -10 " .Dumper(\@t) if $debug;
warn "stores colmn 01 - date of sale: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);#put text between | in array
@t = $stream->get_token;#get closing tag - useless data
warn "Right after -9 " .Dumper(\@t) if $debug;
@t = $stream->get_token;#get opening get_token;#get text between | | tags
warn "Right after -7 " .Dumper(\@t) if $debug;
warn "stores colmn 01 - date of post: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);#put text between | in array
@t = $stream->get_token;#get closing tag - useless data
warn "Right after -6 " .Dumper(\@t) if $debug;
@t = $stream->get_token;#get opening get_token;#get text between | | tags
warn "Right after -4 " .Dumper(\@t) if $debug;
warn "stores column 02 reference #: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);#put text between | in array
@t = $stream->get_token;#get closing tag - useless data
warn "Right after -3 " .Dumper(\@t) if $debug;
@t = $stream->get_token;#get opening get_token;#get text between | | tags
warn "I just read text: " .Dumper(\@t) if $debug;
do {
warn "colmn 03 stores long text b/w 's: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2] .= $t[0][1];#put text between | | in array
@t = $stream->get_token;#get text between | tags
warn "this may be text or may not be text: " .Dumper(\@t) if $debug;
} while ($t[0][0] eq 'T');
$dim2++;
my $span_tag = 0;
@t = $stream->get_token;#get opening tag" . Dumper(\@t) if $debug;
@t = $stream->get_token;#get text for | of column 4 or tag (trans. type)
if ($t[0][0] eq 'T') {
warn "colmn 04 stores transaction type: arry_return[$dim1][$dim2++] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);
}
warn "Right after4 " . Dumper(\@t) if $debug;
if ($t[0][0] eq 'S') { # check if this is an opening tag
$span_tag = 1;
warn "\$span_tag is defined" if $debug;
@t = $stream->get_token;#get text after opening tag
}
warn "colmn 04 transaction type: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);#get text in | and/or tags
if ($span_tag == 1) {
warn "\$span_tag is defined" if $debug;
@t = $stream->get_token;#get closing tag - useless data
# the following only occurs if tags were used in this td
@t = $stream->get_token;#get hanging closing tag (BAD HTML)- useless data
$span_tag = 0;
}
@t = $stream->get_token;#get closing | tag - useless data
warn "closing tag will be processed now: " if $debug;
warn "closing tag: ". Dumper (\@t) if $debug;
@t = $stream->get_token;#get opening tag will be processed now: " if $debug;
warn "opening | tag: " . Dumper (\@t) if $debug;
@t = $stream->get_token;#get tag
warn Dumper (\@t) if $debug;
warn "(get_trans_descr) arry_return[$dim1][$dim2] = ". get_transaction_description($t[0][2]{'onclick'}) if $debug;
$arry_return[$dim1][$dim2++] = get_transaction_description($t[0][2]{'onclick'});
@t = $stream->get_token;#get the opening tag
@t = $stream->get_token;#get text between tags
warn "colmn 06 stores amount \$\$: arry_return[$dim1][$dim2] = $t[0][1]" if $debug;
$arry_return[$dim1][$dim2++] = trim($t[0][1]);#put text between in array
@t = $stream->get_token;#get closing tag - useless data
@t = $stream->get_token;#get closing tag - useless data
@t = $stream->get_token;#get closing | tag - useless data
@t = $stream->get_token;#get closing
tag - useless data
$dim1++;
}
@t = $stream->get_token; #get next token please (tag or text b/w tags)
}
return (@arry_return);
}
sub get_bal {
use HTML::TokeParser;
my ($self) = @_;
# let's go to the summary of accounts page:
$self->get("$main_page");
my $stream = HTML::TokeParser->new(\$self->{content});
#let's start process of getting Statement Balance:
for(my $i=0;$i<8;$i++){#pass 16 opening table tags
$stream->get_tag("table");
}
for(my $i=0;$i<6;$i++){
$stream->get_tag('tr');
}
$stream->get_tag('td');
$stream->get_tag('td');
my $current_balance;
$current_balance= $stream->get_trimmed_text("/td");
$current_balance = money_converter($current_balance);
return ($current_balance);
}
sub avail_credit {
use HTML::TokeParser;
my ($self) = @_;
# let's go to the summary of accounts page:
$self->get("$main_page");
my $stream = HTML::TokeParser->new(\$self->{content});
#let's start process of getting Statement Balance:
for(my $i=0;$i<8;$i++){#pass 15 opening table tags
$stream->get_tag("table");
}
for(my $i=0;$i<12;$i++){#pass 13 opening table tags
$stream->get_tag('tr');
}
$stream->get_tag('td');
$stream->get_tag('td');
my $available_credit;
my @junk;
$available_credit = $stream->get_trimmed_text("/td");
$available_credit = money_converter($available_credit);
return ($available_credit);
}
#sub recent_payments {
# use HTML::TokeParser;
# my ($self) = @_;
# # let's go to the summary of accounts page:
# $self->get("https://www99.americanexpress.com/myca/acctsumm/us/action?request_type=authreg_acctAccountSummary&Face=en_US");
# my $stream = HTML::TokeParser->new(\$self->{content});
# #let's start process of getting Statement Balance:
# for(my $i=0;$i<17;$i++){#pass 16 opening table tags
# $stream->get_tag("table");
# }
# $stream->get_tag('tr');
# $stream->get_tag('tr');
# $stream->get_tag('td');
# my $recent_pay;
# $recent_pay= $stream->get_trimmed_text("/td");
# $recent_pay = money_converter($recent_pay);
# return ($recent_pay);
#}
sub paymnt_due_date {
use HTML::TokeParser;
my ($self) = @_;
# let's go to the summary of accounts page:
$self->get("$main_page");
my $stream = HTML::TokeParser->new(\$self->{content});
#let's start process of getting Statement Balance:
for(my $i=0;$i<8;$i++){#pass 15 opening table tags
$stream->get_tag("table");
}
for(my $i=0;$i<18;$i++){
$stream->get_tag('tr');
}
$stream->get_tag('td');
$stream->get_tag('td');
$stream->get_tag('td');
my $pay_due_date;
$pay_due_date= $stream->get_trimmed_text("/td");
$pay_due_date = date_converter($pay_due_date);
return ($pay_due_date);
}
# pulls value for balance, not for Minimum payment due!!!
sub paymnt_due_amt {
use HTML::TokeParser;
my ($self) = @_;
# let's go to the summary of accounts page:
$self->get("$main_page");
my $stream = HTML::TokeParser->new(\$self->{content});
#let's start process of getting Statement Balance:
for(my $i=0;$i<8;$i++){#pass 16 opening table tags
$stream->get_tag("table");
}
for(my $i=0;$i<16;$i++){
$stream->get_tag('tr');
}
$stream->get_tag('td');
$stream->get_tag('td');
$stream->get_tag('td');
my $pay_due_amount;
#following must return Due Apr 14
$pay_due_amount= $stream->get_trimmed_text("/td");
$pay_due_amount = money_converter($pay_due_amount);
return ($pay_due_amount);
}
sub bal_close_date {#date of last statement balance
use HTML::TokeParser;
my ($self) = @_;
# let's go to the summary of accounts page:
$self->get("$main_page");
my $stream = HTML::TokeParser->new(\$self->{content});
#let's start process of getting Statement Balance:
for(my $i=0;$i<8;$i++){#pass 16 opening table tags
$stream->get_tag("table");
}
for(my $i=0;$i<14;$i++){
$stream->get_tag('tr');
}
$stream->get_tag('td');
$stream->get_tag('td');
$stream->get_tag('td');
my $close_date;
$close_date= $stream->get_trimmed_text("/td");
$close_date = date_converter($close_date);
return ($close_date);
}
sub get_transaction_description {
#this subroutine will receive this as input:
#
#window.open('/StatementDetail?SALE_DATE=04%2F05%2F2005&POSTING_DATE=04%2F05%2F2005&TRANSACTION_TYPE_TEXT=++++++++++&REFERENCE_NUMBER=&PERSON_NAME=&TRANSACTION_AMOUNT=-255.10&FOREIGN_CURRENCY=&MERCHANT_DESCRIPTION=CLICK-TO-PAY+PAYMENT%2C+THANK+YOU+++++++++&SIC_DESCRIPTION=++++++++++++++++++++++++++++++++++++++++&STATEMENT_DATE=04%2F14%2F2005&TITLE_COLOR=%23FFFFFF&SUB_TITLE_COLOR=%23DDDDDD&CHARGED_TO=','DETAIL','resizable=yes,scrollbars,width=600,height=310,top=100,left=100,screenx=100,screeny=100')
#
# and pull "ELECTRONIC+STORES+++++++++++++++++++++++" out of it
my $description_str = shift;
my $return_val;
if ($description_str =~ /^window\.open\(\'\/StatementDetail\?(.*)\'\,\ \'.*\'\)/) {
$description_str = $1;
my @keys_values = split ('\&', $description_str);
my %keys_values_hash;
foreach my $element (@keys_values) {
my ($key, $value) = split('\=', $element);
# let's url-un-encode strings:
# convert '+' to space
$value =~ tr/\+/ /;
# convert embedded comma to space delimiting purposes
$value =~ tr/\,/ /;
# convert hex symbols to alphanumeric
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/ge;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/ge;
$value =~ s///g;
$keys_values_hash{$key} = $value;
}
if ($keys_values_hash{'SIC_DESCRIPTION'}){
$return_val = $keys_values_hash{'SIC_DESCRIPTION'};
} else {
$return_val = '';
}
}
}
sub date_converter {
#original date we are feeding this subroutine is in this format: mm/dd/yy
my ($date_string) = @_;
my (@arry_date) = split(/\//, $date_string);
#format my date like this yyyy-mm-dd
$date_string ="$arry_date[2]-$arry_date[0]-$arry_date[1]";
return ($date_string);
}
sub statement_date_converter {
# receives two arguments: the statement date (2005-04)
# and transaction date (03/22)
# converts a statement transaction date to a mysql date.
# for example, if my statement date is 01/15/2005
# I would have activities ranging from 12/16 to 01/15
# this function turns 12/16 to 2004-12-16 and 01/15 to 2005-01-15
my ($self, $date_statement, $date_transaction) = @_;
my ($date_stat_year, $date_stat_month) = split('\-', $date_statement);
my ($date_trans_month, $date_trans_day) = split('\/', $date_transaction);
my ($date, $year);
if ($date_stat_month == 1){
if ($date_trans_month == 12) {
$year = $date_stat_year - 1;
$date = $year.'-'.$date_trans_month.'-'.$date_trans_day;
} else {
$date = $date_stat_year.'-'.$date_trans_month.'-'.$date_trans_day;
}
} else {
$date = $date_stat_year.'-'.$date_trans_month.'-'.$date_trans_day;
}
return $date;
}
sub money_converter {
#takes values like $234.45 or $234** and converts them in numeric format of 234.45 and 234 respectively
my ($money_to_numeric) = @_;
$money_to_numeric =~ s/\$//g; #replace all dollar signs ($) with nothing, i.e. remove them
$money_to_numeric =~ s/\*//g; #replace all stars (*) with nothing, i.e. remove them
$money_to_numeric =~ s/\,//g; #replace all commas (,) with nothing, i.e. remove them
return ($money_to_numeric);
}
sub trim {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
#remove all for strings
$string =~ s/^\s* \s*$//g;
return $string;
}
sub exact_statement_date {
use HTML::TokeParser;
my ($self, $stat_date) = @_;
my $stat_date_full;
# load the page that has the statements
$self->get("$stat_page");
my $stream = HTML::TokeParser->new(\$self->{content});
my @t;
for(my $i=0;$i<11;$i++){
$stream->get_tag("table");
}
for(my $i=0;$i<4;$i++){
$stream->get_tag("tr");
}
$stream->get_tag("td");
$stream->get_tag("select");
@t = $stream->get_token;# on the