ParseError:嵌套的窗体 [英] ParseError: nested FORMs
本文介绍了ParseError:嵌套的窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Python机械化为此代码提供嵌套的FORMs错误:
Python mechanize gives nested FORMs error for this code:
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()
这都不能解决:
Neither this solves:
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'
也不是:
Nor this:
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'
我已经在python/mechanize在stackoverflow/其他论坛中搜索了嵌套形式错误的Q/A.没有解决办法.
I have searched net for Q/A on nested forms error in python/mechanize in stackoverflow/ other forums. No solutions.
感谢任何(快速)帮助.谢谢.
Any (quick) help is appreciated. Thanks.
推荐答案
看看这个问题,并可能尝试使用 BeautifulSoup 来解析网站,而不是机械化本身,BS会更健壮.
Take a look at this question, and possibly try using BeautifulSoup to parse the website instead of mechanize itself, BS is a little bit more robust.
这篇关于ParseError:嵌套的窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文