javascript - Python adding a new control gives error -


i using mechanize in python . unable set value of selectcontrol element.

the webpage trying crawl http://www.mcxindia.com/sitepages/indexhistory.aspx part source code concerned :

<tr>                             <td bgcolor="#f5f4f5" class="txtblue"><table border="0" align="center" cellpadding="0" cellspacing="0">                                 <tr>                                   <td><table id="mrbtlstspotfut" border="0" style="font-weight:normal;height:85px;width:208px;">                 <tr>                     <td><input id="mrbtlstspotfut_0" type="radio" name="mrbtlstspotfut" value="1" checked="checked" /><label for="mrbtlstspotfut_0">commodity future indexes</label></td>                 </tr><tr>                     <td><input id="mrbtlstspotfut_1" type="radio" name="mrbtlstspotfut" value="0" onclick="javascript:settimeout('__dopostback(\'mrbtlstspotfut$1\',\'\')', 0)" /><label for="mrbtlstspotfut_1">commodity spot indexes</label></td>                 </tr><tr>                     <td><input id="mrbtlstspotfut_2" type="radio" name="mrbtlstspotfut" value="2" onclick="javascript:settimeout('__dopostback(\'mrbtlstspotfut$2\',\'\')', 0)" /><label for="mrbtlstspotfut_2">rainfall indexes</label></td>                 </tr>             </table></td>                                   <td>&nbsp;</td>                                   <td rowspan="3" valign="top"><p style="margin-top: 3px; margin-bottom: 0; margin-left: 0" align="justify">                                      <table width="100%" border="0" cellspacing="0" cellpadding="3">                                       <tr>                                         <td class="tablerowtxt1"> selected index</td>                                         <td>&nbsp;</td>                                         <td colspan="2"><select name="mddlotherindex" id="mddlotherindex" class="dd" style="width:170px;">                 <option selected="selected" value="323">mcxcomdex</option>                 <option value="324">mcxmetal</option>                 <option value="325">mcxenergy</option>                 <option value="326">mcxagri</option>              </select></td> 

now can change value of 2nd radio button doing

br.select_form(nr=0) br.set_all_readonly(false) br.form['mtbfromdate']='08/01/2013' br.form['mtbtodate']='08/08/2013' br.form.set_value(['0'],name='mrbtlstspotfut') 

but want select option value '327' not present(since comes js when radio button clicked, mechanize cannot handle)

so trying add new control form like

<option value="327">mcxenergy</option> 

i trying this, not work.

br.form.new_control('text','option',{'value':'327'}) br.form.fixup() br.form['mddlotherindex']= ['327'] 

but gives me following error:

  file "build\bdist.win-amd64\egg\mechanize\_form.py", line 2006 mechanize._form.itemnotfounderror: insufficient items name '327' 

where going wrong?

i think need create select , option. if don't have select can't choose it.

example of select (option inside of select):

<select>   <option value="volvo">volvo</option>   <option value="saab">saab</option>   <option value="mercedes">mercedes</option>   <option value="audi">audi</option> </select> 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -