Just to give you an idea of the type of PERL script I'm wanting to
replicate in VB:
#!/apps/YourApplicationDirectory/perl/bin/perl
#JEG
use LWP::UserAgent;
use HTTP::Cookies;
use HTML::TreeBuilder;
require "/apps/YourApplicationDirectory/scripts/utils.pl";
CheckLock("/apps/YourApplicationDirectory/pid/get_mycompany_reports.pid");
InitLogger("get_mycompany_xml");
my $tree = HTML::TreeBuilder->new;
my $cjar = HTTP::Cookies->new(
file => "/apps/YourApplicationDirectory/tmp/cookies.txt",
autosave => 1,
ignore_discard => 1
);
my $browser = LWP::UserAgent->new( cookie_jar => $cjar );
Debug("---\n");
Debug("---\n");
Debug("--- get_mycompany_reports.pl Has Begun\n");
Debug("---\n");
Debug("Logging Into mycompany Website\n");
# Log into mycompany Website
my $html = $browser->post(
"https://www.mycompany.com/validate.asp?validate=true",
[
"CompanyID" => "<<<< Your Company ID Here >>>>>",
"UserID" => "<<<< Your User ID Here >>>>>",
"Password" => "<<<< Your Password ID Here >>>>>",
"RememberLogin" => "true"
]
);
Debug("Retrieving Reports List\n");
# Generate the page of reports
$html = $browser->get("https://www.mycompany.com/members/reports.asp");
# Throw the html into a tree and get the value of the first checkbox
# We'll use this later to delete from the list
$tree->parse( $html->content() );
$tree->eof(); # done parsing for this tree
my @filenames;
my @checkboxes;
foreach my $cb ( $tree->find_by_attribute( "type", "checkbox" ) ) {
push @checkboxes, $cb->attr("value");
}
foreach my $a ( $tree->find_by_tag_name("a") ) {
next unless grep { /cccc_rrrr_/ } $a->as_text(); # cccc=CompanyID,
rrrr=ReportType
push @filenames, $a->as_text();
}
$tree->delete; # erase this tree because we're done with it
# Go through all the files we have pulled down and
# check to see if we have already processed them
my $zIndex = 0;
foreach my $filename (@filenames) {
if ( -e "/apps/YourApplicationDirectory/tmp/" . $filename ) {
Debug( "\tWe Already Have File: " . $filename . "\n" );
}
else {
Debug( "We Did Not Have File: " . $filename . "\n" );
Debug( "Pulling Over File: " . $filename . "\n" );
$html =
$browser->get(
"https://www.mycompany.com/members/reports.asp?z=$zIndex");
open( FILE, ">/apps/YourApplicationDirectory/tmp/$filename" )
or die "Can't open $filename: $!\n";
printf( FILE "%s\n", $html->content() );
close(FILE);
Debug( "Calling parse_commercial.pl For File: " . $filename . "\n"
);
system("/apps/YourApplicationDirectory/scripts/parse_commercial.pl
/apps/YourApplicationDirectory/tmp/$filename"); # This is how this
customer parses their files
}
$zIndex++;
}
my $file_count = @filenames;
Debug(
"Currently Their Are " . $file_count . " Reports On The mycompany
Server\n" );
if ( $file_count > 24 ) {
Debug( "Deleteing First Report ("
. $filenames[0]
. ") From mycompany Web Server\n" );
# Finally Delete the first entry in the list
$html = $browser->post(
"https://www.mycompany.com/members/reports.asp",
[
"btnSubmit" => "Submit",
"cb0" => $checkboxes[0]
]
);
}
Debug("get_mycompany_reports.pl Is Now Complete\n");