Thank you
Here is the code I tried, after having read the documentation. To start, I just want to write "Hello" in a reply's form.
#!/usr/bin/perl -Tw
use diagnostics;
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $mech = WWW::Mechanize->new;
# $mech->cookie_jar(
# HTTP::Cookies->new(
# file => "/windows/C/Documents and Settings/xxx
+/Application Data/Mozilla/Firefox/Profiles/xxx.default/cookies.txt",
use LWP::Debug qw(+);
my $url = "http://rootforum/index.php?page=post&forum=forum&category=6
+&topic=452223&option=newpost";
$mech->get($url);
$mech->submit_form(
form_number => 2, # the first form of the page is a search bar
fields => {
message => "Hello",
valid => "Post this message"
},
);
And the response is :
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking forum.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 xxx.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET http://rootforum/index.php?page=post
+&forum=forum&category=6&topic=452223&option=newpost
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 555 bytes
LWP::Protocol::collect: read 416 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 426 bytes
HTTP::Cookies::extract_cookies: Set cookie sessionforum => 471e41c7dd1
+9c424cc3277a5eb068430
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking forum.xxx.com for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header: - checking cookie sessionforum=471e
+41c7dd19c424cc3277a5eb068430
HTTP::Cookies::add_cookie_header: it's a match
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: POST http://rootforum/index.php?page=pos
+t&forum=forum&category=6&topic=452223&option=newpost
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 628 bytes
LWP::Protocol::collect: read 416 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 1440 bytes
LWP::Protocol::collect: read 923 bytes
LWP::UserAgent::request: Simple response: OK
I havn't find the good code to submit the reply, I tried :
#$mech->submit()
# $mech->click_button( name => 'valid' )
# $mech->click_button( value => 'Post this message' );
I wonder if the first problem is not an authentification's one ? |