Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

download with HTML::FORM login and password on page

0 views
Skip to first unread message

Winston75

unread,
Apr 28, 2008, 7:38:13 AM4/28/08
to

hi,

i don't understand my code is corrupted at form "value" instance??
error prompt : Can't call method "value" on an undefined value at
ligne 27 (here : $form->find_input('txtusername')-
>value($user);) ??

any ideas, thanks

#!/usr/bin/perl -w

use strict;
use warnings;
use LWP::UserAgent;
use HTML::Form;

my ($user,$pass ) = qw(username password);
my $base = 'http://www.mysite/login.asp/';

my $ua = LWP::UserAgent->new(agent => 'Microsoft Internet Explorer
6.0' );

my $req = HTTP::Request->new( GET => "${base}" );

my $res = $ua->request($req);
die $res->status_line if not $res->is_success;

my $form = (HTML::Form->parse($res->content, $base))[1];

$form->find_input('txtusername')->value($user);
$form->find_input('txtpassword')->value($pass);

$ua->request($form->click );

Peter Makholm

unread,
Apr 28, 2008, 7:43:18 AM4/28/08
to
Winston75 <baptist...@gmail.com> writes:

> i don't understand my code is corrupted at form "value" instance??
> error prompt : Can't call method "value" on an undefined value at
> ligne 27 (here : $form->find_input('txtusername')-
>>value($user);) ??

> $form->find_input('txtusername')->value($user);

I assume this is line 27?

What you have is that the find_input method on you HTML::Form object
returns undef. According to the documentation this means that there is
no input in the form matching you criteria.

//Makholm

Winston75

unread,
Apr 29, 2008, 12:14:14 PM4/29/08
to
On 28 avr, 13:43, Peter Makholm <pe...@makholm.net> wrote:

thanks for you reponss.
my error was in web adresss:
'http://www.mysite.com/login.asp/';
but
'http://www.mysite.com/login.asp';


OK, next :

#!/usr/bin/perl -w

use strict;
use warnings;
#use diagnostics;

use LWP::UserAgent;
use HTML::Form;

use HTML::SimpleLinkExtor;

my ($user,$pass ) = qw(username password);

my $base = 'http://www.mysite.com/login.asp';


my $ua = LWP::UserAgent->new(agent => 'Microsoft Internet Explorer
6.0' );
my $req = HTTP::Request->new( GET => "${base}" );
my $res = $ua->request($req);
die $res->status_line if not $res->is_success;

my $form = (HTML::Form->parse($res->content, $base))[1];

$form->find_input('txtusername')->value($user);


$form->find_input('txtpassword')->value($pass);

my $base2 ='http://www.mysite.com/database/';
my $ua2 = LWP::UserAgent->new(agent => 'Microsoft Internet Explorer
6.0' );
my $req2 = HTTP::Request->new( GET => "${base2}" );
my $res2 = $ua2->request($req2);
die $res2->status_line if not $res2->is_success;
my $extractor = HTML::SimpleLinkExtor->new($base2);
$extractor->parse($res2->content);
my @allLinks = $extractor->links;


for (@allLinks)
{
if (/DataAge.asp/) {

print $_ . "\n";
}
}


my result & code are correct : print command send me, "www.mysite.com/
DataAge.asp"
however, how to connect on this link, without losing a session with
$user et $pass??
the lib html:linkextractor can extract my link, but not simulate a
CLICK on my new link www.mysite.com/DataAge.asp, for instance.

thanks,

0 new messages