in reply to Re^3: Help required regarding HTTP::Request::Common, File upload
in thread Help required regarding HTTP::Request::Common, File upload
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Help required regarding HTTP::Request::Common, File upload
by Corion (Patriarch) on Apr 29, 2008 at 13:38 UTC | |
by KarthikK (Sexton) on Apr 29, 2008 at 14:56 UTC |