I'm doing some web scraping and falling short.
#!/usr/local/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; use 5.010; my $mech = WWW::Mechanize::Firefox->new( autoclose => 0, ); my $url = q(https://selfservice.mypurdue.purdue.edu/prod/bwckctlg.p_disp_dyn_ctl +g?); $mech->get($url); say q(got url); say q(choose term); $mech->form_number(1); $mech->field('cat_term_in', '201220'); $mech->submit(); say q(choose subject); $mech->form_number(1); $mech->select('sel_subj', ['AAE']); $mech->submit(); say $mech->content();
This will generate.
got url choose term choose subject 2 elements found for './/*[(local-name(.)="input" or local-name(.)="se +lect" or local-name(.)="textarea") and @name="sel_subj"]' at ./get_co +urse_descriptions2.pl line 28
I think this is because the html for the page has:
<FORM ACTION="/prod/bwckctlg.p_display_courses" METHOD="POST"> <INPUT TYPE="hidden" NAME="term_in" VALUE="201220"> <INPUT TYPE="hidden" NAME="sel_subj" VALUE="dummy"> ^^^^^ Relavant Hidden Input Type <SNIPPED HTML> vvvvvvvvv Relevant Select Name <SELECT NAME="sel_subj" SIZE="3" MULTIPLE ID="subj_id"> <OPTION VALUE="AAE">AAE-Aero & Astro Engineering
How the do I get it to properly select a value? I think the problem lies in that there is a hidden input type of the same name as the select. The select has a label and id defined but I'm not sure how to use those. I think this script might work in plain WWW::Mechanize but it just returns the same page without giving me this error. Thanks, gizmo

In reply to WWW::Mechanize::Firefox, select with multiple names by gizmo_mathboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.