Leser: 21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!C:\\Programme\\Perl\\bin use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; my $outfile = "out.htm"; my $url = "http://testhost.com/mainpage"; my $username = "test"; my $password = "testpw"; my $mech = WWW::Mechanize->new(); my $formname = "form1"; $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($url); $mech->form_name($formname); $mech->field(userName => $username); $mech->field(password => $password); $mech->click(); my $output_page = $mech->content(); open(OUTFILE, ">$outfile"); print OUTFILE "$output_page"; close(OUTFILE);
2010-05-19T11:36:33 pqich tippe auf:
$mech->success
das kannst du abfragen, ob ein fehler vorlag oder nicht.
im fehlerfall $mech->res->message
my $mech = WWW::Mechanize->new( autocheck => 0 );
use CGI::Carp qw/ fatalsToBrowser /;