Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

WWW::Mechanize Forms...

by lstacey (Initiate)
on Dec 14, 2015 at 22:23 UTC ( [id://1150294]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks,

I am looking to become familiar with the WWW::Mechanize Module. I am trying to learn how to automate inputs in some fields but dont quite understand why I see different outputs with the following code at different uri....

#!/usr/bin/perl -w use WWW::Mechanize; use strict; my $mech = WWW::Mechanize->new(); $mech->get("https://www.google.com/"); #$mech->get("https://www.southwest.com/"); print $mech->uri(); print "\n"; my @theForms = $mech->forms(); print $#theForms."\n"; #How many forms are returned in the array foreach my $form (@theForms) { my @inputfields = $form->param; foreach my $input (@inputfields){ print $input."\n"; } }

When I navigate to google.com, I get this output listing the size of the form array and the fields within each form object

https://www.google.com/ 0 ie hl source biw bih q btnG btnI gbv

When I navigate to southwest.com, I get this output telling me there are no forms? Why might this be?

https://www.southwest.com/ -1

Thanks in advance!

Replies are listed 'Best First'.
Re: WWW::Mechanize Forms...
by Corion (Patriarch) on Dec 14, 2015 at 22:26 UTC

    Have you looked at the HTML of the respective pages?

    When I go to https://www.southwest.com/ with Javascript disabled, I see a comment that the site does not work with Javascript disabled. Maybe the site does not work with browsers that don't support Javascript. See the FAQ on Javascript support of WWW::Mechanize.

      Yep...that's it...I assumed getting the true statement from

      print $mech->is_html();

      meant that I would be able to use the site. Thank you for your help!

        <noscript> <meta http-equiv="refresh" content="0;url=/html/errors/javascript_di +sabled.html"> </noscript>
        Well, it is valid HTML after all, isn't it? Just not very Mechanize-friendly…

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1150294]
Approved by choroba
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-16 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found