为什么我的RoboBrowser表单提交不起作用?

2022-07-06 12:57:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用RoboBrowser将表单数据发布到一个php网站。为什么我要面对“robobrowser.exceptions.InvalidSubmitError无效“错误?你知道吗

我尝试了许多在网上共享的解决方案,但都没有成功。你知道吗

import re
from robobrowser import RoboBrowser
import requests

br = RoboBrowser()
br.open("https://bombayhighcourt.nic.in/case_query.php")
form = br.get_form()
print(form)
# print(form['m_hc'].value)
form['m_hc'] = '01'
form['m_sideflg'] = 'C'
form['m_sr'] = 'R'
form['m_skey'] = 'AO'
form['m_no'] = ''
form['m_yr'] = ''
# form['submit1'] = 'Search By Case No'
form['frmdate'] = '01-06-2018'
form['todate'] = '01-06-2019'
form['submit11'] = 'List By Case Type'
form.action = 'https://bombayhighcourt.nic.in/case_query.php'
print(len(list(form.submit_fields.items(multi=True))))
print(br.session.cookies['PHPSESSID']) # BAh7Bzo...
print(br.session.headers['User-Agent']) # a python robot
# form.serialize()
print(form)
br.submit_form(form)
# br.submit_form(form, submit11)
# submit_field = form.action
# submit_field.value = 'List By Case Type'
# br.submit_form(form, submit=submit_field)
# src = str(br.parsed())
# print(str)
# form['password'] = "FILL_PASSWORD_IN"
# br.submit_form(form)
# src = str(br.parsed())
# start = '<li class="header-bal">Earned: '
# end = '</li>'
# result = re.search('%s(.*)%s' % (start, end), src).group(1)
# print(result)

我的错误率正在下降。请支持:

    raise exceptions.InvalidSubmitError()
    robobrowser.exceptions.InvalidSubmitError

Tags: brimportrobobrowserformsrcfieldbyexceptionsphpsubmitcaseprintstrinvalidsubmiterror