Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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.

Replies are listed 'Best First'.
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( '' ) 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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-04-26 21:51 GMT
Find Nodes?
    Voting Booth?