My script :<form action="./index.php?page=identify&forum=mxxx&option=iden +tify" method="post"> <table style="width: 90%; margin-left: aut +o; margin-right: auto;"> <tbody><tr> <td colspan="2"> <div class="titlesection">Pers +onal Informations</div> </td> </tr> <tr> <td>Pseudo</td> <td><input name="nick" size="20" t +ype="text"></td> </tr> <tr> <td>Password</td> <td><input name="password" size="2 +0" type="password"></td> </tr> </tbody></table> <table style="width: 100%;"> <tbody><tr> <td style="width: 50%; text-align: + center;"><input value="Cancel" onclick="window.location='./index.php +?forum=xxx'" type="button"></td> <td style="width: 50%; text-align: + center;"><input value="Valider" type="submit"></td> </tr> </tbody></table> <div class="center"><a href="./index.php?p +age=identify&forum=xxx&option=forgotpass">I've forgotten my p +assword</a></div> </form>
And the response :#!/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=i +dentify"; $mech->get($url); $mech->set_fields( nick => '$username' , password => '$password' ) ; $mech->click( "Valider");
I don't understand why this field "password" is uncorrect when I look the source-code of tghe login page. I log in the forum and save it with Live HTTPLWP::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 => 738be3f1601f4 +ffeb2fdba53b05e9808 LWP::UserAgent::request: Simple response: OK Uncaught exception from user code: No such field 'password' at /usr/lib/perl5/site_perl/5.10.0/WW +W/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/200 +8070400 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=(organ +ic)|utmcmd=organic|utmctr=navipromo.zip%20ini2; Ap01net=1; keyxxx=3jn +EVeaXDFtmnspk3eg4XXPp442aY3DR; __utma=213901525.86146944302048160.121 +3438880.1213438880.1213726837.2; __utmz=213901525.1213438880.1.1.utmc +sr=google|utmccn=(organic)|utmcmd=organic|utmctr=Firefox%203; pseudo= +xxx; __utma=267689497.3761709358129836500.1212511832.1218923881.12189 +65039.366; sessionxxx=0b74663dbcf58ad8de498b0659dfe9ce; __utmb=267689 +497.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-A +ug-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
In reply to Re^4: Post in a forum
by epb711
in thread Post in a forum
by epb711
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |