[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: 7128
Joined: Mon Aug 01, 2005 8:47 am
Location: Ơ̸̦͇̲̬̭̱̰͎̞͈̣͎͚̳ͬ͋̃̀̇͊͂͋͐ͦ̽ͣ̂ͥ͊̅̀̚͠ B̶͖̯͉̜̰̲̓̔͋̈́ͅ È̯ Y̪̤̼͉̠̙͝

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

Post by Isaac » Mon Jul 07, 2014 10:24 am

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.
s☼-£♦и̫͍ͥ̍ͪ͌̓͗͡о̡̹̱͊̅ͮ̓̕͢б̧̝̻̪̤̳̜͐̓̉ͤ͢͜ ͙̬͙̆̑ͮ̐ͭ̾̂́͘i̎̌̾̓̽̀̈̓̀҉͉̙̦͎̘̝͕f̻͕͔̘ͣͣ̓͊̿͢͜ ͍͔͈͕̮̫ͣ̆ͮ̊͋/♂6Æ!♪╩"▲L└уͭ̂͐̇҉̴̣̼̞̠̯͓̺̞ф̜̊͌̈́̋̏̐́ц̨͔̮̿̇ ̨̛͖̙͖̖̮̗̱ͩ̆͞ͅа̥͇̞̖͚̟̅͐ͤ͞͠͠э̜̘̩̳̬͔̾ͯ̀ͫ̒̐̿ͅͅг̭̖̀ͦ̒̑ͥ̌ͮͫ͞ё͔̟̃ͬ̾̓͟ё̦̞̙̫͔̩͑̀͂ͯ̄̔̃̑̀͠ͅͅ
User avatar
Jeff250
DBB Master
DBB Master
Posts: 6387
Joined: Sun Sep 05, 1999 2:01 am
Location: ☃☃☃

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

Post by Jeff250 » Mon Jul 07, 2014 1:01 pm

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: 7128
Joined: Mon Aug 01, 2005 8:47 am
Location: Ơ̸̦͇̲̬̭̱̰͎̞͈̣͎͚̳ͬ͋̃̀̇͊͂͋͐ͦ̽ͣ̂ͥ͊̅̀̚͠ B̶͖̯͉̜̰̲̓̔͋̈́ͅ È̯ Y̪̤̼͉̠̙͝

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

Post by Isaac » Mon Jul 07, 2014 2:47 pm

>> "Thank You!"*1000000000000000000

You are a real hero!
s☼-£♦и̫͍ͥ̍ͪ͌̓͗͡о̡̹̱͊̅ͮ̓̕͢б̧̝̻̪̤̳̜͐̓̉ͤ͢͜ ͙̬͙̆̑ͮ̐ͭ̾̂́͘i̎̌̾̓̽̀̈̓̀҉͉̙̦͎̘̝͕f̻͕͔̘ͣͣ̓͊̿͢͜ ͍͔͈͕̮̫ͣ̆ͮ̊͋/♂6Æ!♪╩"▲L└уͭ̂͐̇҉̴̣̼̞̠̯͓̺̞ф̜̊͌̈́̋̏̐́ц̨͔̮̿̇ ̨̛͖̙͖̖̮̗̱ͩ̆͞ͅа̥͇̞̖͚̟̅͐ͤ͞͠͠э̜̘̩̳̬͔̾ͯ̀ͫ̒̐̿ͅͅг̭̖̀ͦ̒̑ͥ̌ͮͫ͞ё͔̟̃ͬ̾̓͟ё̦̞̙̫͔̩͑̀͂ͯ̄̔̃̑̀͠ͅͅ
Post Reply