http://www.perlmonks.org?node_id=62051


in reply to How to submit name & password using LWP ?

The following snippet of code does the same thing no matter which "nickname" and "password" are entered. How can the client tell if they have been accepted or rejected?
use LWP::UserAgent; use HTTP::Request::Common; $ua = LWP::UserAgent->new; my ($response, $url) = clickon("", ''); ($response, $url) = clickon($response->content, 'content="\d+;url=([^" +]+)'); ($response, $url) = clickon($response->content, 'location.href="([^"]+ +)"'); ($response, $url) = clickon($response->content, 'frame name="login" sr +c="([^"]+)"'); $response = $ua->request(POST $url, [nickname => "JohnSmith", password + => "test"]); print $response->content; print $response->message; sub clickon { my $content = shift @_; my $filter = shift @_; if ($content =~ /$filter/m) { print "\n\n*********MATCH($1)*******\n\n"; my $url = "http://www.friendscout.de$1"; return ($ua->request(GET $url), $url); } else { die "redirect not found !"; } }