【问题标题】:How to deal with nested forms?(ERROR: mechanize._form.ParseError: nested FORMs)如何处理嵌套表单?(错误:mechanize._form.ParseError:嵌套表单)
【发布时间】:2016-02-14 06:01:39
【问题描述】:

我正在尝试在网站中提交表单,当我运行代码时,它给了我错误:

mechanize._form.ParseError: 嵌套表单

所以我查了一下,在网站上,有 2 个表格在彼此内部。 我需要的第一个表单已正确关闭。

有没有办法解决这个问题?

【问题讨论】:

    标签: python mechanize


    【解决方案1】:
    br.select_form(name = "frmName") if name of the form is stated, otherwise
    br.select_form(nr=0) which means you are accessing the first form with index 0(nr=0)
    

    【讨论】:

    • 我需要的表格没有名字,只有id。我使用此代码来调用我想要的确切形式:“def select_form(form): return form.attrs.get('id', None) == 'email-form' br.select_form(predicate=select_form)” 但仍然我收到嵌套表单错误
    【解决方案2】:

    br.select_form(predicate=lambda f: f.attrs.get('id', None) == 'email-form') 这可能有助于您选择表格的功能..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      • 2011-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多