0

i have a form which is used for authentication. but in this form there are no submit button but it has used an <input> as a button . now i am confused how to click this type of button with MECHANIZE.

page details

till now i had done this:

import urllib
import re
import mechanize
from base64 import b64encode

and can this be done in Java script?

br = mechanize.Browser()


response = br.open("http://xyz.com");
#print response.code
#print response.geturl()

br.select_form("login")
br.form['j_username'] = 'user'
br.form['j_password'] = 'pass'
RATHI
  • 5,129
  • 8
  • 39
  • 48

2 Answers2

2

That's not an error. Read the response - it's a filelike object.

br.select_form("login")
br.form['j_username'] = 'xyz'
br.form['j_password'] = 'pass'
pag2 = br.submit()
html = pag2.read()
print html
DivinusVox
  • 1,133
  • 2
  • 12
  • 27
  • @MilchePatern Tempted to PEP8 it. ;) – DivinusVox Aug 29 '13 at 22:29
  • the page that is coming after submitting is the same page with error.. onclicking the button some javescript code runs.. is mechanize support the javascript in it? – RATHI Aug 30 '13 at 11:47
  • @RATHI Mechanize has no javascript engine. you can often get around javascript by just posting/getting from the url where the javascript would have. – DivinusVox Aug 30 '13 at 14:31
1

This is a submit button. A submit button in HTML is by definition an <input> element of type submit.

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175