机械化以提交和阅读响应

时间:2015-05-01 16:15:01

标签: python response mechanize

我在python中使用mechanize提交表单并打印出响应,但它似乎不起作用

import mechanize

# The URL to this service
URL = 'http://sppp.rajasthan.gov.in/bidsearch.php'


def main():
    # Create a Browser instance
    b = mechanize.Browser()
    # Load the page
    b.open(URL)
    # Select the form
    b.select_form(nr=0)
    # Fill out the form
    b['ddlfinancialyear'] = '2015-2016'
    b.submit()
    b.response().read()

我要做的是使用网址'sppp.rajasthan.gov.in/bidsearch.php';提交表单,并在提交表单时(通过尝试将值'2015-2016'传递给' ddfinancialyear'控制)另一页应作为回复返回,我没有得到任何输出。

1 个答案:

答案 0 :(得分:-1)

尝试在阅读之前指定b.submit

S = b.submit()
S.read()