gpt4 book ai didi

python - 如何使用多 Mechanize python选择单选按钮

转载 作者:行者123 更新时间:2023-12-04 16:22:02 26 4
gpt4 key购买 nike

我有一个简单的 php 表单,我想使用 multimechanize 选择单选按钮,我可以选择填充文本字段,但我不确定如何使用单选按钮或复选框...

我尝试了以下但不起作用

    # select first (zero-based) form on page
br.select_form(nr=0)
# set form field
br.form['name'] = 'foo'
br.form['email'] = 'foo@foo.com'
br.form['gender'] = 'male'

<form method="post" action="/mechanize/index.php">
Name: <input type="text" name="name" value="">
<span class="error">* </span>
<br><br>
E-mail: <input type="text" name="email" value="">
<span class="error">* </span>
<br><br>
Website: <input type="text" name="website" value="">
<span class="error"></span>
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<span class="error">* </span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>

最佳答案

br.form.find_control(name="gender").value = 'male'
br.submit()

关于python - 如何使用多 Mechanize python选择单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22797444/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com