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

I have a page I want to automate but the form doesn't have a name/id and the form number changes cause it's dynamic. The form ACTION of this form is "http://www.lyricsdownload.com". Is there any way using WWW::Mech I can search for this?
  • Comment on www::mech looking for specific form action

Replies are listed 'Best First'.
Re: www::mech looking for specific form action
by davidrw (Prior) on Jun 30, 2006 at 03:25 UTC
    yup -- search through the $mech->forms array (elements are HTML::Form objects) for the one you want (yes could be slightly more efficient w/a loop instead of grep).
    my @forms = $mech->forms; my ($form_number) = grep { $forms[$_-1]->action eq 'http://www.lyricsd +ownload.com' } 1 .. @forms; $mech->submit_form( form_number => $form_number, fields => { ... }, );