baron has asked for the wisdom of the Perl Monks concerning the following question:

I am using LWP::UserAgent to enter a nickname and password in an authentification page. Everything ok there.

But, the next page is mainly :

<body onload="javascript:document.formulaire.submit()"> <form method="post" name="formulaire" actions="https://etc...> <input type="Hidden" name="login" value="...."> <input type="Hidden" name="password" value="....">

Can I get though?

Thanks for answering.

Pierre (France)

20040303 Edit by Corion: Added code tags and formatting

Replies are listed 'Best First'.
Re: Authentification with LWP
by Abigail-II (Bishop) on Apr 03, 2004 at 10:07 UTC
    Can I get though?
    If a browser can, so can a Perl program. How is of course a different question. From the limited stuff you show, it seems a javascript issue, where the form is submitted as soon as the page loads. So I suggest you send a request that mimics submitting the form. You might want to use WWW::Mechanize for that.

    Abigail

Re: Authentification with LWP
by Aragorn (Curate) on Apr 03, 2004 at 13:11 UTC
    I found the following code in the LWP docs:
    # Create a user agent object use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); # Create a request my $req = HTTP::Request->new(POST => 'http://search.cpan.org/search'); $req->content_type('application/x-www-form-urlencoded'); $req->content('query=libwww-perl&mode=dist'); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }
    It seems to me that by changing the POST => 'http://search.cpan.org/search' and the $req->content('query=libwww-perl&mode=dist'); lines you can change the example into something you want.

    Arjen

Re: Authentification with LWP
by inman (Curate) on Apr 03, 2004 at 17:39 UTC
    The form action is an HTTPS page. You need to make sure that you have enabled HTTPS for LWP. There are notes on how to do this in the LWP documentation but you will need Crypt::SSLeay to be installed and running. This uses OpenSSL to provide the SSL functionality.

    If you are trying to install this on Windows using PPM and Activestate Perl then you will need to use the repositories hosted at the university of winnipeg http://theoryx5.uwinnipeg.ca

Re: Authentification with LWP
by bradcathey (Prior) on Apr 03, 2004 at 13:09 UTC
    I know this is a bit OT, and a small point, but please know that hidden input is not safe input, if you indeed are trying to pass anything securely.

    Good luck.


    —Brad
    "A little yeast leavens the whole dough."