我尝试登录网站https://everest.ioe.edu.np/lanusers/dialup.php,然后点击“更改密码”链接,更改密码并使用机械化注销,并使用以下代码:
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()
代码成功登录,点击更改密码链接,然后转到更改密码页面然后显示 “ParseError:嵌套的FORMs错误”
请大师帮我弄清楚我的机器人无法正常工作的原因。