gpt4 book ai didi

选择表单时出现 Python Mechanize 错误

转载 作者:太空宇宙 更新时间:2023-11-04 01:08:54 25 4
gpt4 key购买 nike

我要提交的网站代码:::FORM PART OF WEBSIDE CODE


选择表单时出现的错误

Traceback (most recent call last):
File "call.py", line 35, in <module>
loginAccount()
File "call.py", line 15, in loginAccount
browser.select_form(nr = 0)
File "/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 499, in select_form
global_form = self._factory.global_form
File "/usr/lib/python2.7/dist-packages/mechanize/_html.py", line 544, in __getattr__
self.forms()
File "/usr/lib/python2.7/dist-packages/mechanize/_html.py", line 557, in forms
self._forms_factory.forms())
File "/usr/lib/python2.7/dist-packages/mechanize/_html.py", line 237, in forms
_urlunparse=_rfc3986.urlunsplit,
File "/usr/lib/python2.7/dist-packages/mechanize/_form.py", line 844, in ParseResponseEx
_urlunparse=_urlunparse,
File "/usr/lib/python2.7/dist-packages/mechanize/_form.py", line 981, in _ParseFileEx
fp.feed(data)
File "/usr/lib/python2.7/dist-packages/mechanize/_form.py", line 760, in feed
raise ParseError(exc)
mechanize._form.ParseError: expected name token at '<!\\\\])/g,"\\\\$1").rep'

源代码(我写了像# ERROR OCCUR HERE 这样的注释):

   browser = mechanize.Browser()
browser.set_handle_robots(False)
browser.set_handle_refresh(False)
browser.open("https://accounts.google.com/ServiceLoginAuth")
browser.select_form(nr = 0)
browser.form['Email'] = "MYMAIL@gmail.com"
browser.form['Passwd'] = "MYPASWORD"
browser.submit() # Till the here, works fine. I can login.

resp = browser.open("https://accounts.google.com/b/0/SmsAuthSettings?Setup=1")
resp = resp.read()
browser.select_form(nr = 0) # ERROR OCCUR HERE

当我删除 browser.select_form(nr = 0) 时,程序运行正常。我该怎么办?

最佳答案

使用更健壮的解析器,例如浏览器 = mechanize.Browser(factory=mechanize.RobustFactory())

查看此链接以获得更多帮助: http://www.thecodingforums.com/threads/mechanize-select_form-issue.359575/

关于选择表单时出现 Python Mechanize 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28889990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com