开发者

Forms not getting submitted with MECHANIZE in PYTHON!

from  mechanize import *
import cookielib
from BeautifulSoup import BeautifulSoup

br = Browser()
br.open('http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp')
br.select_form(name="main")
br.find_control(name="disclaimer").selected = True
reponse = br.submit()
print reponse.read()

The Above is my code. Now I expect it to show 开发者_开发知识库the HTML of this http://casesearch.courts.state.md.us/inquiry/processDisclaimer.jis but it is not doing so instead returning the HTML of the same page. I do not get why?


Add .items[0]:

br.find_control(name="disclaimer").items[0].selected

A fuller code snippet looks like this:

import mechanize

br = mechanize.Browser()
br.open('http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp')
br.select_form(name="main")
br.find_control(name="disclaimer").items[0].selected = True
reponse = br.submit()
print reponse.read()


You're skipping some bits. I'm surprised it's not exploding.

reponse = br.submit()
print reponse.read()

should be:

br.submit() # returns nothing
print br.response().read()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜