in reply to Using WWW::Mechanize

The ->get URL is wrong.

Upd Sorry, that was probably a typo; there is a different problem.

First: $mech->get returns the redirect page, and that does not have the necessary form. Use https://www.soundclick.com/community/memberlogin.cfm?action=logoutdone&email=&ErrorMessage=Please%20log%20in as the URL.

Second: WWW::Mechanize does not have an input_name method, only form_name.

This seems to work:

use strict; use WWW::Mechanize; use HTTP::Cookies; my $mech = WWW::Mechanize->new( agent =>"Mozilla/5.0 (X11; U; Li +nux i686; en-US; rv:1.7) Gecko/20040918 Firefox/0.9.3 "); my $i = 0; my $usr = "username"; my $pw = "password"; $mech->get("https://www.soundclick.com/community/memberlogin.cfm?actio +n=logoutdone&email=&ErrorMessage=Please%20log%20in"); $mech->cookie_jar( HTTP::Cookies->new() ); if( $mech->content() =~ /CFForm_1/ ){ $mech->form_name("CFForm_1"); $mech->field( email => $usr ); $mech->field( password => $pw ); $mech->click(); if ($mech->success() ) { if ( $mech->content() =~ /My personal member profile/ ) { print "User $usr logged in successfully!\n" ; } else { print " User $usr was unable to log in successfully!\n"; } } }

Replies are listed 'Best First'.
Re^2: Using WWW::Mechanize
by 80degreez (Initiate) on Apr 26, 2007 at 23:28 UTC
    I'm still receiving no output whatsoever on the cmd prompt when I launch it.

      If you're anything like me, it didn't work for me either. I added a last line:

      else { print $mech->content }

      ... and got the following output:

      LWP will support https URLs if the Crypt::SSLeay module is installed. More information at <http://www.linpro.no/lwp/libwww-perl/README.SSL>.

      Try going there, reading that, and installing Crypt::SSLeay.



      --chargrill
      s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
        Yep. I should've used autocheck => 1 in WWW::Mechanize->new's parameters; that would've reported it.

        autocheck => 1 is a good idea anyway.