【发布时间】:2011-09-18 04:33:15
【问题描述】:
我试图进行机械化解析的 html 是:
<select id="topic_id2" name="topics[]" title="blabla" tabindex="4" class="createSelect">
here go options
但是在它的正下方有另一个下拉菜单,代码如下:
<select id="topic_id3" name="topics[]" title="optional" tabindex="5" class="createSelect">
现在,如果它有帮助,我不需要从后者中选择任何值,因为它是可选的。
当我尝试时
br = mechanize.Browser()
br.select_form(name="form")
br["topics[]"] = ["Internet"]
我明白了:
mechanize._form.AmbiguityError: more than one control matching name 'topics[]'
有没有一种方法可以根据控件的 id 选择控件,使用 mechanize.Browser()(同时保留所有其他表单语法)?
谢谢
【问题讨论】:
-
您可以通过表单中的索引访问控件,请参阅此答案stackoverflow.com/questions/6482308/…
-
你能 +1 链接中的答案吗?