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

Some years ago, I used to work with WWW::Mechanize, where you POST'ed something via a call like

$mech->post($url, \%data2post);

Today I started to study WWW::Mechanize::PhantomJS (kind of the hottest thing nowadays), and it turned out that the old-style calls (as above) no longer work, producing an error with HTTP::Request::Common.

Naturally, neither there are books/manuals on this new module, nor, sadly, any comprehensive examples on the Web to be found on the matter. Would greatly appreciate some experience on POST in the module shared.

Replies are listed 'Best First'.
Re: POST in WWW::Mechanize::PhantomJS
by Corion (Patriarch) on Jul 20, 2014 at 06:41 UTC

    WWW::Mechanize::PhantomJS does not currently support POST requests via ->post, because Selenium does not support POST requests unless they are triggered by a form in the current HTML page.

      So, update the dom with a new form from ->post, then submit said form? It should work :D (I'm guessing naturally)

        This is the approach I plan to take eventually. The code is already there, but I still have to trick Selenium into actually returning the results.

        Selenium is not really intended for browser automation. It is more intended for simulating user intaction and so it provides very little programmatic interfaces to query the result state of a request.

      Well... Thanks!
Re: POST in WWW::Mechanize::PhantomJS
by Anonymous Monk on Jul 20, 2014 at 02:12 UTC

      Been there, done that, got the scar. :)

      Browsed all of the above before asking the question, thanks. Tried to send %data2post with "params", then with "data", neither worked. Can't even figure out the difference between "params" and "data".

      Have you tried to POST something yourself, by chance?