Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: multiple selections in the same field using Mechanize

by keszler (Priest)
on Dec 09, 2011 at 01:02 UTC ( #942532=note: print w/replies, xml ) Need Help??


in reply to multiple selections in the same field using Mechanize

Setting a select field with multiple values allowed is documented at http://search.cpan.org/~abeltje/Win32-IE-Mechanize-0.009/lib/Win32/IE/Mechanize.pm#$ie-%3Eselect%28_$name,_\@values_%29:

$ie->select( $name, \@values ) Given the name of a select field, set its value to the value specified. If the field is not <select multiple> and the $value is an array, only the first value will be set. Passing $value as a hash with an n key selects an item by number (e.g. {n = 3> or {n = 2,4}>). The numbering starts at 1. This applies to the current form (as set by the form() method or defaulting to the first form on the page).
So,
$ie->select( 'parms', [ 'var1', 'var2' ]); or @multi_values = ('var1','var2'); $ie->select( 'parms', \@multi_values);

Replies are listed 'Best First'.
Re^2: multiple selections in the same field using Mechanize
by Anonymous Monk on Dec 09, 2011 at 01:10 UTC
    ++

    :) Your reading comprehension is most excellent

      .. And thanks, A.M., for trying :)
Re^2: multiple selections in the same field using Mechanize
by Anonymous Monk on Dec 09, 2011 at 16:48 UTC

    Thank you, Keszler - that .. nearly works. The multiple fields get highlighted, but then it becomes a fail with this error,

    "Use of unitialized value in list assignment at C:\PERL..\IE\Input.pm line 115"

    ... and this is the entire script:

    ----------------------------

    my $url = "http://www.mesonet.org/index.php/weather/daily_data_retriev +al"; my $ie =Win32::IE::Mechanize->new( visible=> 1 ); my @variables = ('TAVG','DAVG','PAVG','HMAX','HMIN','HAVG','WSPD','ATO +T'); $ie->get($url); sleep 1; $ie->form_name("request"); $ie->set_fields(beginmonth=>'05'); $ie->set_fields(beginday=>'15'); $ie->set_fields(beginyear=>'2010'); $ie->set_fields(endmonth=>'07'); $ie->set_fields(endday=>'06'); $ie->set_fields(endyear=>'2010'); $ie->select( 'parms', \@variables); $ie->set_fields(stid=> $station); $ie->click("SUBMIT"); my $html = $ie->content; print $html; $ie->close;

    -----------------------

    ... any other glaring errors on my part, or is it IE::Mech?

      .. and this is the offending line 115 in Input.pm:

      %vals = map { ( $_ => undef ) } @values;

      But I'm such a newbie to Perl, I can't parse what's in the brackets?
        NM. It DOES work!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942532]
help
Chatterbox?
[LanX]: Choroba: do you miss chaos with ties? apply at the US government.. ;)
[ambrus]: Corion: those are good rules.
[ambrus]: Discipulus: oh sure. the input data has different filenames every time I get them.
[ambrus]: the directory structure may be 1, 2, or 3 deep, it may have spaces in the filename or not, it has dates in various format, different keywords for the same meanings, and the dates and other keywords are assembled in various ways.
[Discipulus]: no ambrus by specification i mean for example license per core instead of per socket, so fields are different

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2017-03-29 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.