复选框输入使用python机械化 [英] Checkbox input using python mechanize
本文介绍了复选框输入使用python机械化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用python mechanize填充表单。形式如下:
I want to fill a form using python mechanize. form looks like:
<POST https://10.20.254.39/cloud_computing/vmuser/migrate_vm/cli multipart/form-data
<TextControl(vm=cli)>
<TextControl(chost=10.20.14.39)>
<SelectControl(dhost=[*, 28, 27])>
<CheckboxControl(live=[on])>
<CheckboxControl(undefinesource=[on])>
<CheckboxControl(suspend=[on])>
<SubmitControl(<None>=Submit) (readonly)>
<HiddenControl(_formkey=85819e5a-02bb-42c8-891f-3ddac485438b) (readonly)>
<HiddenControl(_formname=migrate_create) (readonly)>>
如何将live或undefinesource(checkbox)的值设置为True(打勾)或False untick)
live和undefinsource的项目是:
How do i set the value of live or undefinesource (checkbox) to True(ticked) or False(untick) Items of live and undefinsource are:
>>> print br.form.controls[4].get_items()
[<Item name='on' id='migrate_undefinesource' checked='checked' name='undefinesource' type='checkbox' id='migrate_undefinesource' value='on' class='boolean'>]
>>> print br.form.controls[3].get_items()
[<Item name='on' id='migrate_live' checked='checked' name='live' type='checkbox' id='migrate_live' value='on' class='boolean'>]
推荐答案
我这样做的一种方法是
br.find_control("live").items[0].selected=True
这篇关于复选框输入使用python机械化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文