in reply to WWW::Mechanize to Fill in Fields when no Form Defined

If there is no <form>, then it can't be submitted without Javascript. WWW::Mechanize does not handle Javascript.

See WWW::Scripter and/or Win32::IEAutomation or WWW::Mechanize::Firefox for alternatives that handle Javascript.

Replies are listed 'Best First'.
Re^2: WWW::Mechanize to Fill in Fields when no Form Defined
by cavac (Prior) on Apr 01, 2011 at 22:14 UTC

    If there is no <form>, then it can't be submitted without Javascript.

    That's technically not correct. It can't (shouldn't) be submitted by a browser, but there is no reason why you can't do it in Perl. You can view what's going on by using wireshark or something similar. Then, just take the response you captured, and communicate to the server directly using IO::Socket::IP. Just replay the communication with your changes.

    If you really want the missing <form> elements, hack your own proxy with HTTP::Proxy.

    If you need to "simulate" a full blown browser session, you could try WWW::Mechanize::Firefox. If you are desperate (or want to have some fun with Pay-per-click advertising), there are also the modules X11::GUITest and Win32::GuiTest.

      There is no need to go down to raw socket communication. After investigating what happens, you can create the appropriate form as HTML::Form object and use WWW::Mechanize to send the data from the form.

        Syncing expectations to reality ... done.

        Uhm, yeah, you're right.

        That's probably one of the side effects of developing your own webserver i guess. Sometimes i assume that talking HTTP is easy for everyone (and that HTML is something everyone unterstands anyway). A bit of reality check now and then seems like a good idea.

        Thanks.