in reply to Using WWW::Mechanize
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 | |
by chargrill (Parson) on Apr 27, 2007 at 00:48 UTC | |
by akho (Hermit) on Apr 28, 2007 at 12:35 UTC |