Help with file download.

J

Jim Simpson

My bank allows me to download a .csv file of my account and I'm trying to
automate the process. So far I've gotten into the download manager sheet but
after hours and hours of work I've been unable to get any further. The
download manager sheet contains 2 forms plus a "download Button" - one form
is a 1 of 2 choice drop down menu the other is a 1 of 10 choice radio button
form. Can someone please help me. A portion of my code follows:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# secure login
my $ua = LWP::UserAgent->new();
$ua->protocols_allowed( ['https'] );
$ua->cookie_jar(HTTP::Cookies->new(file => ".cookies.txt", autosave =>
1));
my $response = $ua->post($https_login, [ 'username' => "$https_user",
'password' => "$https_pass", 'submit' => 'Submit' ] );
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
}
else
{
open my $fh, '> myfile.html' or die $!;
print $fh $response -> content;
close $fh;
}

# get download manager sheet.
if ($response->content() =~ (/.*<a\s+href="(.*)">Account\s+Download/))
{
my $nav_url = $baseurl . $1;
my $response2 = $ua->post($nav_url);
if ($response2->is_error())
{
printf " %s\n", $response2->status_line;
print "https request error!\n";
}
else
{
open my $fh, '> myfile2.html' or die $!;
print $fh $response2 -> content;
close $fh;
}
}
else
{
printf " %s\n", $response->status_line;
print "https request error!\n";
}

# Get "download.csv".
my $csvresponse = $ua->post($burl . $1, [ 'name' => "name of dropdown
form", 'VALUE' => "$https_value2", 'NAME' => 'name of Radio button form',
'VALUE' => "$https_value1", 'name' => "name of button", 'value' =>
"Download Data"] );

if ($csvresponse->is_error())
{
printf " %s\n", $csvresponse->status_line;
print "https request error!\n";
}
else
{
open my $fh, '> myfile3.html' or die $!;
print $fh $csvresponse -> content;
close $fh;
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
After running the above, my file2.html and myfile3.html both show the
download manager sheet. I hope I have included enough info. If not I will be
happy to provide more detail.

Thanks for all help.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top