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

Hi brother monks, I just started using UserAgent. I'm trying to logon to a site and having some difficulty.
The login page has two forms and a submit button:
INPUT NAME="LogInName" VALUE=""
INPUT NAME="PIN" input type = password
INPUT TYPE=submit VALUE="Continue"

I have this so far but how do I activite the submit button?
$ua = new LWP::UserAgent;
my $req = POST '$URL', | LogInName => 'blah', PIN => 'dadida' |;*
print $ua->request($req)->as_string;

*I was unable to get the left and right brackets to print - used | instead
Your help is greatly appreciated as always.

Replies are listed 'Best First'.
Re: Submitting a form w/ UserAgent
by chromatic (Archbishop) on Jun 30, 2000 at 01:50 UTC
    Here's some code I pulled out of perldoc lwpcook and modified to use the POST request to grab this very question:
    use HTTP::Request::Common qw( POST ); use LWP::UserAgent; my $ua = new LWP::UserAgent; my $req = POST 'http://perlmonks.org/index.pl', [node_id => '20494']; print $ua->request($req)->as_string;
    HTTP::Request::Common handles quoting and encoding for you. If you like your way better, you'll need the following:
    $req->content_type('application/x-www-form-urlencoded'); $req->content('node_id=20494');
    before you call $ua->request() on it.