擅长:python、mysql、java
<p>很抱歉让一篇死了很久的帖子复活,但这仍然是我在谷歌上能找到的最好的答案,它不起作用。经过比我想承认的更多的时间,我终于明白了。红外线对形状物体来说是正确的,但对其他物体却不正确,他的密码也不起作用。下面是一些对我有效的代码(尽管我确信存在一个更优雅的解决方案):</p>
<pre><code># Select the form
br.open("http://www.website.com/")
br.select_form(nr=0) # you might need to change the 0 depending on the website
# find the carrier drop down menu
control = br.form.find_control("carrier")
# loop through items to find the match
for item in control.items:
if item.name == "203":
# it matches, so select it
item.selected = True
# now fill out the rest of the form and submit
br.form['number'] = "mynumber"
br.form['from'] = "herpderp@gmail.com"
br.form['subject'] = "Yellow"
br.form['message'] = "Hello, World!"
response = br.submit()
# exit the loop
break
</code></pre>