Filling out a login form using mechanization, python

I tried to enter the site https://everest.ioe.edu.np/lanusers/dialup.php , and then click the "change password" link, change the password and log out using the mechanize with the following code fragment:

import mechanize def tryinglogin(): browser = mechanize.Browser(factory=mechanize.RobustFactory()) browser.set_handle_robots(False) r = browser.open("https://everest.ioe.edu.np/lanusers/dialup.php") #surfing web page browser.select_form(nr=0) # Find first form of web page browser.form["name"] = "067bce001" browser.form["password1"] = "abc" pass="password1" browser.submit() # submit html = browser.response().readlines() # Read the response, html for i in range(0,len(html)): if '<u>Your current LAN account status</b>' in html[i]: # filter out one line print(html[i]) browser.find_link(text='Change password') req = browser.click_link(text='Change password') browser.open(req) #print browser.response().read() #print html of logged in page r = browser.open(req) # surfing web page ,no problem upto here in code browser.select_form(nr=0) browser.form["password"] = "abc" browser.form["password1"] = "bcdef" # change password field browser.form["password2"] = "bcdef" #verify password field browser.submit() if __name__ == "__main__": tryinglogin() 

the code successfully logs in, clicks the link to change the password and goes to the password change page, but then shows "ParseError: FORM nested error"

please, gurus help me understand why my bot is not working.

+4
source share

All Articles