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 ?

In reply to Re^2: Post in a forum by epb711
in thread Post in a forum by epb711

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.