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

I tried the below code to login in perlmonks, but it says oops wrong login. where am i going wrong. I am not getting any error message.

use strict; use WWW::Mechanize; my $url = "http://www.perlmonks.com"; my $mech = WWW::Mechanize->new(autocheck => 1);#create the object $mech->get( $url ); print $mech->content,"\n"; $mech->submit_form( form_number =>2, fields => {user => 'myname', passwd => 'password'} ); my $content = $mech->content(); $mech->success ? print "yes" : print "no";

Replies are listed 'Best First'.
Re: Question in WWW::Mechanize
by Limbic~Region (Chancellor) on Apr 07, 2006 at 13:51 UTC
    Anonymous Monk,
    I can't test this because my local proxy/firewall isn't playing nice. You may also want to check out PerlMonks::Mechanized (beta).
    #!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $url = 'http://perlmonks.org'; my $mech = WWW::Mechanize->new(autocheck => 1); $mech->get($url); $mech->form_number(2); $mech->field('user' => 'myname'); $mech->field('passwd' => 'password'); $mech->click_button(name => 'login'); my $content = $mech->content(); print $mech->success() ? 'yes' : 'no';

    Cheers - L~R

Re: Question in WWW::Mechanize
by spadacciniweb (Curate) on Apr 07, 2006 at 13:42 UTC
    Why don't you use ethereal for trouleshooting?