Thanks Mate! I re-wrote everything using WWW::Mechanize and its working now! Change i had done is, instead of having calling the URL, i wrote a HTML page, with the necessary parameters and hosted in a webserver and accessing it via WWW::Mechanize
MY code
use WWW::Mechanize;
use HTTP::Cookies;
my $user = 'userid';
my $pass = 'password';
my $login_url = 'https://myserver.com/login';
my $upload_url = "http://mylocalserver/File_Upload.html";
my $file = "C:\\ExportFile.csv";
$ENV{HTTPS_PROXY} = 'http://proxyserver'
$ENV{HTTPS_PROXY_USERNAME} = 'user';
$ENV{HTTPS_PROXY_PASSWORD} = 'pwd';
$ENV{HTTP_PROXY} = 'http://proxyserver';
$ENV{HTTP_PROXY_USERNAME} = 'usre';
$ENV{HTTP_PROXY_PASSWORD} = 'pwd';
my $cookie_jar = HTTP::Cookies->new(file => 'cookies.txt',autosave =>
+1);
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->proxy(https => undef);
$mech->proxy(http => undef);
$mech->credentials( $user => $pass );
$mech->get( $login_url );
my $response = $mech->response();
$cookie_jar->extract_cookies($response);
$cookie_jar->save(); #added new
$mech->cookie_jar($cookie_jar);
$mech->get($upload_url);
$mech->form_number(1);
$mech->set_fields(theFile => $file); #'thefile' id control name in the
+ HTML page
$mech->submit();
die unless ($mech->success);
Is it possible to have this HTML page in local machine ex: C:\fileupload.html and access it via WWW::Mechanize? i get protocol error
Thanks for your tips
Cheers
Karthik
|