Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: WWW::Mechanize::Firefox question

by Corion (Pope)
on Oct 15, 2012 at 07:57 UTC ( #999022=note: print w/ replies, xml ) Need Help??


in reply to WWW::Mechanize::Firefox question

$mech->click_button(name => 'Get anagrams');

is the thing that should work. You don't tell me how it fails for you, so I can't advise further on that front.

If WWW::Mechanize::Firefox tells you

I don't know which form to submit, sorry.

... that means that there is more than one form on the page. Use ->form_name or ->form_number to set the "current form", as documented in WWW::Mechanize::Firefox.


Comment on Re: WWW::Mechanize::Firefox question
Select or Download Code
Re^2: WWW::Mechanize::Firefox question
by Joie (Initiate) on Oct 16, 2012 at 03:23 UTC

    Thank you for your reply. I played around with it some more and looked at the form information on the page. I realized that there were 2 forms, I amended the code to:

    #!/usr/bin/perl use strict; use diagnostics; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new(); print "What word would you like to know the anagrams of?\n"; my $word = <STDIN>; $word = chomp( $word ); $mech->get( 'http://www.wordsmith.org/anagram/index.html' ) or die "Un +able to access page.\n"; $mech->form_number(2); $mech->field( 'anagram', $word ); $mech->submit_form; wait until $mech->success(); print $mech->content;

    Now it has no error messages; however, it seems to be printing the original website, rather than the results of my query.

       wait until $mech->success(); ?? That seems like an error

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999022]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (18)
As of 2015-07-06 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (80 votes), past polls