Newbie HTTP::Request->new(POST => URL); question

Q

qa4ever

Perl gurus,

My Internet provider is providing a login screen before one gets access to
internet.
I was thinking of automate login using following script but it won't login.
Why is it failing?

use strict;
use LWP;
use URI::Escape;
use constant URL => 'http://10.0.0.6/sd/init';
my $ua = LWP::UserAgent->new;
my $newagent = 'search_rfc/1.0 (' . $ua->agent .')';
$ua->agent($newagent);
my $query_string = 'username=joeb&password=lowe';
print "echo $query_string";
my $request = HTTP::Request->new(POST => URL);
$request->content($query_string);
my $response = $ua->request($request);
die $response->message unless $response->is_success;
print "echo $response->as_string\n";


View source of 'http://10.0.0.6/sd/init' >>>>>>>>>>>>>>>>>>>>>>>>>>><

<body onload="document.pwdenter.username.focus();">
<FORM NAME="pwdenter" ACTION="login" METHOD="POST">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"
HEIGHT="100%">
<TR><TD>
<CENTER>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR><TD>
<IMG SRC="/bzinfo/catv/logo1.gif" ALT="logo" BORDER="0">
<FONT SIZE="-1" FACE="Geneva, Arial">
<BR><BR>
Enter username and password.<BR>
Thereafter Press "Log on".
<BR><BR>
Användarnamn:
<BR><INPUT NAME="username"><BR>
Lösenord:
<BR><INPUT NAME="password" TYPE=PASSWORD
onBlur="this.form.username.focus();">
<BR>
<INPUT TYPE="SUBMIT" NAME="submitForm" VALUE="Log on">
</TABLE>
</TABLE>
</FORM>
</body>

Thanks,
QA4Ever
 
B

Brian McCauley

qa4ever said:
Perl gurus,

BTW, this has nothing to do with Perl.
my $request = HTTP::Request->new(POST => URL);

View source of 'http://10.0.0.6/sd/init' >>>>>>>>>>>>>>>>>>>>>>>>>>><
<FORM NAME="pwdenter" ACTION="login" METHOD="POST">
Look! ^^^^^^^^^^^^^^

If that hint isn't sufficient for you to see what you've done wrong then
you need to step back and get a basic grounding in HTTP and HTML before
trying to do any web client automation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top