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

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7736
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

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

Post 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.
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6530
Joined: Sun Sep 05, 1999 2:01 am
Location: ❄️❄️❄️

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

Post 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().
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7736
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

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

Post by Isaac »

>> "Thank You!"*1000000000000000000

You are a real hero!
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
Post Reply