python - Unable to set the value of a SelectControl element -


i trying machine-parsable bus schedule data submitting form mechanize.

however, stymied mechanize syntax setting

import mechanize br = mechanize.browser() br.open("http://www.planibus.sto.ca/hastinfoweb/starttimetableform.aspx") br.select_form(name="timetablequeryform") br["routedirectiondynamiccombobox$combobox_input"] = "10 ottawa" # works fine, it's textcontrol br["datepicker$daysdropdownlist"] = ["3"] # selectcontrol ### mechanize._form.itemnotfounderror: insufficient items name '3' 

mechanize._form.itemnotfounderror: insufficient items name '3' looks needs list, when enter more 1 item in list (which makes little sense, given date picker) get:

mechanize._form.itemcounterror: single selection list, must set sequence of length 0 or 1

i thought original ["3"] sequence of length 1?

thanks attention. i'm missing obvious...

edit: note '3' above 1 value, , web site allows values next 2 weeks in ui, depending on when see this, list of allowable values change. substitute '3' 1 of allowable values... still doesn't work me...

3 isn't 1 of available select options, options see are

<option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> 

so try br["datepicker$daysdropdownlist"] = ["4"] , code should work.

edit: i've tried looking @ page in question mechanize, try this

import mechanize br = mechanize.browser() br.open("http://www.planibus.sto.ca/hastinfoweb/starttimetableform.aspx") br.select_form(name="timetablequeryform") select = br.form.controls[8] # datepicker$daysdropdownlist select.possible_items() >>> [] 

there aren't options, imagine javascript used populate them after page has loaded. unfortunatly mechanize doesn't support javascript, try using selenium webdriver scrape data need.


Comments

Popular posts from this blog

sql - text truncated using perl DBI insert -

c++ - Is it possible to compile a VST on linux? -

php - Pass object by reference or value -