我试图让 mechanize 从页面中选择一个表单,但有问题的表单在 html 中没有“名称”属性。我应该怎么办?当我尝试使用时
br.select_form(name = "")
我收到错误,没有使用该名称声明任何表单,并且该函数需要名称输入。页面上只有一个表单,我可以通过其他方式选择该表单吗?
最佳答案
试试:
br.select_form(nr=0)
选择第一个表单
在 Mechanize source ,
def select_form(self, name=None, predicate=None, <b>nr=None</b>):
"""
...
nr, if supplied, is the sequence number of the form (where 0 is the
first).
"""
关于Python Mechanize 选择一个没有名字的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2582580/