tonyl has asked for the wisdom of the Perl Monks concerning the following question:

(Please excuse my question as I am new to both Perl and Mechanize.)

I have this Login page which I am trying to perform a form submit. Below is part of my script so far...

mech->get('http://acemeweb01/webapp/common/login_JSF.faces'); $mech->form_name('loginForm'); $mech->field('domain_name', 'DEFAULT'); $mech->field('user_name','user'); $mech->field('password','welcome'); $mech->click();
but when I examine the traffic, I notice it does not work because it is missing the additional query string rnd=(some random number). Is there a method I can add additional query string to the POST? I also tried to use post method by appending the query string at the end of the url but then none of the post data are included.

Any pointer is appreicated.

Tony

Replies are listed 'Best First'.
Re: How to add additional Query String in Post via Mechanize
by almut (Canon) on Jan 09, 2010 at 02:45 UTC

    In case you have a reasonably recent version of HTML::Form (being used under the hood) - i.e. one which has the strict method - you should be able to add new fields to the form simply by setting them (strict is off by default) — meaning you won't get "No such field..." errors (as in older versions before v5.817 / 2008-10-10):

    ... $mech->field('password','welcome'); $mech->field('rnd','...some random number'); # <-- possibly new $mech->click();

    The additional 'rnd' field/parameter will get submitted just as the original ones.

Re: How to add additional Query String in Post via Mechanize
by Massyn (Hermit) on Jan 09, 2010 at 02:45 UTC

    perhaps... $mech->field('rnd',int(rand(100000000000)));

    just above your $mech->click()?

    Sorry, your question is just a little bit too vague to really help you.