Guys, I'm trying to use mechanize to automate my checking of my local Subaru dealer's page. I would like to check his inventory of B9 Tribecas. In order to do that, I need to set the options for the search on his page. The section of HTML on his site looks like this:
<div class="qsFormElement" id="qsMake"> <select name="make" onChange="myQuickSearch.setMake(this.options[t +his.selectedIndex].value)"> <option></option> </select> </div> <div class="qsFormElement" id="qsModel"> <select name="model" onChange="myQuickSearch.setModel(this.options +[this.selectedIndex].value)"> <option></option> </select> </div> <div class="qsFormElement" id="qsTrim"> <select name="trim" onChange="myQuickSearch.setTrim(this.options[t +his.selectedIndex].value)"> <option></option> </select> </div>
Whenever I try to set any value in any of these fields, I get an "Illegal value" error from Mechanize. I also saw that there was some code that seems to populate the options, it looks like this:
//construct new QuickSearch object, passing inventory JSData object var myQuickSearch = new QuickSearch(invJSData); function initQuickSearch(){ // this is to turn off sorting in the api; options will be display +ed in JSDO order criteriaList[MODEL_NAME].setIsPreSorted(true); criteriaList[TRIM_NAME].setIsPreSorted(true); myQuickSearch.setShowNullSearchTypes(false); myQuickSearch.init(document.forms.quickSearchForm); // if there is no "new" inventory, the "New" option does not appea +r in the dropdown. if (myQuickSearch.hasNew) setSearchType("new"); else if (myQuickSearch.hasPreowned) setSearchType("preowned"); } /* Call in the onClick of the search dropdown */ setSearchType = function(newType) { // REQUIRED: this kicks off the dropdown population. myQuickSearch.setSearchType(newType); // by default it will load all makes; this is how you get it to lo +ad models for just one make. if (newType == "preowned") myQuickSearch.setMake("Subaru"); }
Anyone know how I would automate this page? Thanks!

In reply to WWW::Mechanize & <option>s by FrankRizzo

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.