Page 1 of 1

[python][html]Can't get error. (Shortened question)

Posted: Mon Jul 07, 2014 10:24 am
by Isaac
Can any of you get a login error using this code? The program produces test.html, which should have a login error.

Code: Select all

#!/usr/bin/env python
import mechanize
def twc():
	theurl = 'https://services.twc.state.tx.us/UITAXSERV/security/logon.do' 
        br = mechanize.Browser()
	br.set_handle_refresh(False)
	br.set_handle_robots(False)
	br.open(theurl)
	print br.title()
	print br.geturl()
	def pageview(p):
		f=open("test.html","w")
		f.write(p)
		f.close()		
	br.select_form("logonForm")	
	br.form["username"] = "dkfdf"#un
	#br.form["password"] = ""#pw
	print "entered user info"
	br.submit()
	html= br.response().read()
	pageview(html)
	print br.title()
	print br.geturl()
twc()	

The error, in .errorsHeader, should appear like this:

Please correct the following errors:
Password: Enter 6 to 32 characters.


The server should print this around line 283 in the html.

Re: [python][html]Can't get error. (Shortened question)

Posted: Mon Jul 07, 2014 1:01 pm
by Jeff250
Mechanize isn't picking up the submit button, possibly because the HTML is bad.

Add

Code: Select all

br.form.new_control('submit', 'method:logon', {'value': 'Logon'})
before you call submit().

Re: [python][html]Can't get error. (Shortened question)

Posted: Mon Jul 07, 2014 2:47 pm
by Isaac
>> "Thank You!"*1000000000000000000

You are a real hero!