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

My question is akin to that posed at http://www.webmasterkb.com/Uwe/Forum.aspx/perl/29478/WWW-Scripter-or-Javascript-and-perl I am trying to control a dropdown menu through perl:
<label for="search_rpp">Results per page:</label> <select id="search_rpp"> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> <option value="40" selected>40</option> </select>
I know it is controlled by Javascript but I can't seem to make any headway. I also can't seem to download wsp.pl from http://www2.research.att.com/sw/tools/wsp/ because it is asking me for a username and password. Here is the code I have so far.
#!/usr/bin/perl use strict; use WWW::Scripter; my $m = WWW::Scripter->new(); $m->use_plugin('JavaScript'); $m->agent_alias('Windows IE 6'); my $zip1 = '91502'; my $keyword = 'restaurants'; my $url = 'http://www.yelp.com'; $m->get($url); $m->forms; $m->form_number(1); $m->field('find_desc',$keyword); $m->field('find_loc', $zip1); $m->submit(); $m->select('search_rpp', '40'); $m->click();
This produces the following error "Input "search_rpp" not found". I assume this is because the select method requires the argument to be the name, which is missing. P.S. This is my first post so please excuse any failure to conform to the monastery's conventions.

Replies are listed 'Best First'.
Re: WWW::Scripter Help
by Corion (Patriarch) on May 14, 2011 at 06:18 UTC

    You will need to find out how to manipulate nameless elements in WWW::Scripter. I guess you can evaluate Javascript within WWW::Scripter, so I would do that to change the state of the select field.

      Well. I guess that is my question: how do I manipulate nameless elements in WWW::Scripter?

        I would read WWW::Scripter, and likely the ->document method returns a HTML::DOM object that you can use to manipulate the DOM of the current page, regardless of (un)named elements.