Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Completely Confused with Mechanize::Firefox Forms

by daxim (Chaplain)
on Jul 12, 2013 at 17:15 UTC ( #1044033=note: print w/replies, xml ) Need Help??

in reply to Completely Confused with Mechanize::Firefox Forms

use HTML::Form qw(); for my $form ($mech->forms) { print Dumper(HTML::Form->parse($form->{outerHTML}, $mech->uri)); }

Replies are listed 'Best First'.
Re^2: Completely Confused with Mechanize::Firefox Forms
by help_3452 (Initiate) on Jul 12, 2013 at 17:36 UTC

    Ok that's great, thank you very much BUT now I'm a bit more confused!
    This is the blurb from the Mechanize::Firefox documentation

    " $mech->current_form() print $mech->current_form->{name}; Returns the current form. This method is incompatible with WWW::Mechanize. It returns the DOM <form> object and not a HTML::Form instance."

    Thank you nonetheless! Is there 'proper' way to do this ?? Or is the documentation wrong / inaccurate !

      Hi there. I'm not clear on what you want exactly. You just want the names of the forms? WWW::Mechanize has a dump_forms method- so you may not need Mechanize::Firefox. Also, If you use the firefox 'firebug' extension, you can inspect any html element and then use the name or value in the script to mechanize what you want to do..

        Ok cool I'll give that a go. My whole idea though is to try to avoid having to use firebug. I've been making scripts by hand for a little while and I wanted to take the time to make something a little more intelligent. I do understand I can only cover relatively simple scenarios, but i want to take more of the leg work out of setting up a scraper. Cheers all the same.

        Ah ok ! Fair enough.

        What I'm trying to do is make a simplified 'web scraper' Frequently within our Org I need to collect data from various systems ( say checking the names on the internal colleague register )

        But we have many systems and some use javascript. Because of this I was leaning towards Mech::Firefox since it handles it for you.

        I envisaged putting in the internal web address, then receiving back a set of links, forms, etc which the user could then select. I would save the choices in a config file and so allow the user to avoid repetitive checks.

        So i'm bit confused by the answer as it suggest using HTML::Form but the documentation states it doesn't return this type of object. I'd like to understand it properly as I intend to expand the code substantially

Re^2: Completely Confused with Mechanize::Firefox Forms
by Anonymous Monk on Jul 13, 2013 at 07:43 UTC
    forns returns HTML::Form objects, so they're already HTML::Form objects, why reparse?
      bahm, firefox doesn't return HTML::Form objects

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044033]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2018-06-20 02:42 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.