####
#!/usr/bin/perl -Tw
use diagnostics;
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $mech = WWW::Mechanize->new;
my $username = "Username1";
my $password = "Password";
use LWP::Debug qw(+);
$mech->cookie_jar(
HTTP::Cookies->new(
file => "/home/xxx/Documents/Scripts/xxx/Cookie.txt",
autosave => 1,
ignore_discard => 1,
)
);
my $url = "http://forum.xxx/index.php?page=identify&forum=xxx&option=identify";
$mech->get($url);
$mech->set_fields( nick => '$username' , password => '$password' ) ;
$mech->click( "Valider");
####
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking forum.xxx for cookies
HTTP::Cookies::add_cookie_header: Checking .xxx.com for cookies
HTTP::Cookies::add_cookie_header: Checking xxx.com for cookies
HTTP::Cookies::add_cookie_header: Checking .xxx.com for cookies
HTTP::Cookies::add_cookie_header: Checking xxx.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET http://forum.xxx.com/index.php?page=identify&forum=xxx&option=identify
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 556 bytes
LWP::Protocol::collect: read 3296 bytes
LWP::Protocol::collect: read 959 bytes
HTTP::Cookies::extract_cookies: Set cookie sessionxxx => 738be3f1601f4ffeb2fdba53b05e9808
LWP::UserAgent::request: Simple response: OK
Uncaught exception from user code:
No such field 'password' at /usr/lib/perl5/site_perl/5.10.0/WWW/Mechanize.pm line 1371
at /usr/lib/perl5/vendor_perl/5.10.0/HTML/Form.pm line 457
HTML::Form::value('HTML::Form=HASH(0x8a0c1ac)', 'password', '$password') called at /usr/lib/perl5/site_perl/5.10.0/WWW/Mechanize.pm line 1371
WWW::Mechanize::set_fields('WWW::Mechanize=HASH(0x88f078c)', 'nick', '$username', 'password', '$password') called at ./MH_Login.pl line 21
####
http://xxx/index.php?page=identify&forum=xxx&option=identify
POST /index.php?page=identify&forum=xxx&option=identify HTTP/1.1
Host: xxx.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1) Gecko/2008070400 SUSE/3.0.1-2.1 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.com/index.php?page=identify&forum=xxx
Cookie: __utmz=267689497.1218604837.348.15.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=navipromo.zip%20ini2; Ap01net=1; keyxxx=3jnEVeaXDFtmnspk3eg4XXPp442aY3DR; __utma=213901525.86146944302048160.1213438880.1213438880.1213726837.2; __utmz=213901525.1213438880.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=Firefox%203; pseudo=xxx; __utma=267689497.3761709358129836500.1212511832.1218923881.1218965039.366; sessionxxx=0b74663dbcf58ad8de498b0659dfe9ce; __utmb=267689497.68.10.1218965039; __utmc=267689497
Content-Type: application/x-www-form-urlencoded
Content-Length: 42
nick=xxx&password=xxx
HTTP/1.x 200 OK
Date: Sun, 17 Aug 2008 13:05:29 GMT
Server: Apache/2.2.8 (Unix) PHP/5.2.5
X-Powered-By: PHP/5.2.5
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Software: Xxx-2.2
Set-Cookie: keyxxx=3jnEVeaXDFtmnspk3eg4XXPp442aY3DR; expires=Mon, 17-Aug-2009 13:05:29 GMT; path=/
Set-Cookie: utilisateur=3jnEVeaXDFtmnspk3eg4XXPp442aY3DR; expires=Mon, 17-Aug-2009 13:05:29 GMT; path=/; domain=.01net.com
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 4806
Keep-Alive: timeout=1, max=1000
Connection: Keep-Alive
Content-Type: text/html