in reply to Re^2: Help required regarding HTTP::Request::Common, File upload
in thread Help required regarding HTTP::Request::Common, File upload

I wonder how we can improve the documentation of WWW::Mechanize and the frequently asked questions on WWW::Mechanize to make it more obvious to you how to find the answers you need. Maybe you can help us reformulate the parts of the documentation to make it more accessible?

If you have specific parts of the documentation that are unclear to you, please ask about them.

  • Comment on Re^3: Help required regarding HTTP::Request::Common, File upload

Replies are listed 'Best First'.
Re^4: Help required regarding HTTP::Request::Common, File upload
by KarthikK (Sexton) on Apr 29, 2008 at 13:30 UTC
    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

      Yes - you can load a local file into WWW::Mechanize by using the file:// protocol instead of using http://.

        thx Mate! i got it working. I was reluctant because I have to use modified PERL version v 5.6.1. Now i was told i can use Activestate perl and hence i can download these modules via PPM.
        Thanks once again for your help

        Cheers,
        Karthik