in reply to using WWW::Mechanize with more than 1 submit button

The buttons must be in different forms of that page, otherwise it makes no difference to the receiving CGI. So select the right form() and then click() on the button.

For interactive exploration of a website, there is also WWW::Mechanize::Shell (written by me), which allows you to play with WWW::Mechanize in a more interactive manner and afterwards dump your session as Perl code.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.
Re^2: using WWW::Mechanize with more than 1 submit button
by adrianh (Chancellor) on Mar 01, 2003 at 18:23 UTC
    The buttons must be in different forms of that page, otherwise it makes no difference to the receiving CGI.

    Yes it can, since they can have different values. This is perfectly legal.

    <form action="foo.html" method="get"> <p> <input type="hidden" name="foo" value="bar" /> <input type="submit" name="where" value="next" /> <input type="submit" name="where" value="prev" /> </p> </form>

    The value of where is depends on the submit button that is pressed.

    To answer the original question - it does seem to be a lack in the current W::M API - probably worth dropping a line to the author. He seems a friendly chap :-)

      Indeed - that's a difference I didn't notice (or banished from my mind). That page won't work with IE then, as IE (in my recollection) always sends the NAME of the button instead of the value (what an idiot move, who wants to receive the REPRESENTATION back ...). With Mozillla that page should work though. Or that page does parse the representation as well.

      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

        It works in MSIE 4 & 5 - although I can easily believe it breaks on some versions :-)