Python mechanize为此代码提供了嵌套的FORMs错误:
url = 'http://bis.zju.edu.cn/psi/'
browse = mechanize.Browser()
browse.set_handle_robots(False)
browse.open(url)
# print [n for n in browse.forms()]
# ParseError: nested FORMs
browse.select_form(name="form1") # or (nr=0)
# ParseError: nested FORMs
seq = '>seq1' + '\n' + 'MNANSSAKLGDSA'
browse['sequence'] = seq
response = browse.submit()
这两个都没有解决:
browse = mechanize.Browser(factory=mechanize.RobustFactory())
browse.set_handle_robots(False)
browse.open(url)
print [n for n in browse.forms()]
# [] # empty list
browse.select_form(name="form1") # or (nr=0)
# FormNotFoundError: no form matching name 'form1'
也不是这样:
browse = mechanize.Browser()
browse.set_handle_robots(False)
response = browse.open(url)
# 'modify response' (anyway? to remove erroneous html?)
browse.set_response(response)
print [n for n in browse.forms()]
# [] # empty list
browse.select_form(name="form1") # or (nr=0)
# FormNotFoundError: no form matching name 'form1'
我在stackoverflow /其他论坛中搜索了python / mechanize中的嵌套表单错误的网页上的Q / A.没有解决方案。
任何(快速)帮助表示赞赏。感谢。