Drop down menu 带有mechanize的复选框和文本区域
我有一个带有java脚本的html表单,其中包含文本字段、下拉菜单和复选框。我想用python代码填充html表单。表单有两个按钮,一个是“应用”,第二个是“提交更改”,首先单击“应用”,然后提交更改。 HTML代码如下所示:Drop down menu 带有mechanize的复选框和文本区域,drop-down-menu,mechanize,checkbox,python-2.6,Drop Down Menu,Mechanize,Checkbox,Python 2.6,我有一个带有java脚本的html表单,其中包含文本字段、下拉菜单和复选框。我想用python代码填充html表单。表单有两个按钮,一个是“应用”,第二个是“提交更改”,首先单击“应用”,然后提交更改。 HTML代码如下所示: <form id="my_form" action="/temp/var/index" method="POST"> <fieldset id="my_fieldset" style="width:1330px"> <h3 style
<form id="my_form" action="/temp/var/index" method="POST">
<fieldset id="my_fieldset" style="width:1330px">
<h3 style="margin:1px;margin-left:20px;"> MY Form <div class='helps' id='helpform'> </div></h3>
<p><label for="help_no" id="label_help" class="help_code" style="width:80px;margin:1px;float:left;text-align:right;">add a Help:</label>
<input type="text" name="help_no" id="help_no" class="text ui-corner-all help_code" style="width:100px;margin:1px;float:left;"/>
<label for="helptype" id="label_helptype" class="help_code" style="width:60px;margin:1px;float:left;text-align:right;">Help type:</label>
<select id='helptype' class=" ui-widget-context help_code" style="width:100px;margin:1px;float:left;">
<option value="PHelp">Help1</option>
<option value="THelp">Help2r</option>
<option value="IHelp">Help3r</option>
</select>
<p><input type="checkbox" name="comment" id="comment" class=" ui-corner-all help_code" style="margin:1px;margin-left:20px;float:left;"/>
<label for="comment" id="label_commment" class="help_code" style="margin:1px;margin-left:3px;clear:left;" >add comment to Helps</label></p>
<p><input type='button' id='btn_code' style="width:120px;float:left;margin:10px;margin-top:2px;" value='Apply' disabled/>
<p><label style="float:left;margin:1px;text-align:left;color:red;font-weight:bold;">Note:Select results from table, input help information and click Apply.Finally, click Submit Changes.</label></p>
<input type='button' id='btn_submit' style="width:120px;float:right;margin:10px;" value='Submit Changes' disabled /> </p>
</fieldset>
</form>
但我不知道如何设置下拉菜单和复选框的值。
如果有更好的方法,请让我知道 您应该使用所选的
表单
:
br.form['help_no'] = '12345'
br.form['helptype'] = ['THelp'] # a list, so you could have multiple selected
br.form.find_control('comment').items[0].selected = True
br.form['help_no'] = '12345'
br.form['helptype'] = ['THelp'] # a list, so you could have multiple selected
br.form.find_control('comment').items[0].selected = True