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!