Python mechanize登录到帐户-表单未提交

Python mechanize登录到帐户-表单未提交,python,forms,authentication,mechanize,Python,Forms,Authentication,Mechanize,我正在尝试使用Python和mechanize登录我的银行网站 我已经查看了所有以前发布的内容,但仍然无法登录。我想这可能与我提交表格的方式有关。“提交”按钮的HTML为: <input type="image" id="logon" src="https://chaseonline.chase.com/images/logon.gif" onclick="return check_all_fields_logon_RSA_Auth(document.getElementById('Us

我正在尝试使用Python和mechanize登录我的银行网站

我已经查看了所有以前发布的内容,但仍然无法登录。我想这可能与我提交表格的方式有关。“提交”按钮的HTML为:

<input type="image" id="logon"
src="https://chaseonline.chase.com/images/logon.gif" onclick="return
check_all_fields_logon_RSA_Auth(document.getElementById('UserID'),
document.getElementById('Password'));" width="58" height="21" border="0"
title="Log On" tabindex="7">
如果登录成功,那么页面应该是“Chase Online-我的帐户”


我做错了什么?

几个月前,我也在尝试做类似的事情,但是在ESPN。机械化给了我问题,然后有人给了我答案

答案是硒。


否则,在运行脚本时到底出了什么问题?它会产生错误吗?错误说明了什么

不,没有错误。它只是没有进入表单提交后的页面。我用:
print br.title()
import mechanize
from bs4 import BeautifulSoup
import urllib2 
import cookielib
from time import sleep

chase_url = 'https://chaseonline.chase.com/Logon.aspx'

# Browser 
br = mechanize.Browser() 

# Enable cookie support for urllib2 
cookiejar = cookielib.LWPCookieJar() 
br.set_cookiejar( cookiejar ) 

# Broser options 
br.set_handle_equiv( True ) 
br.set_handle_gzip( True ) 
br.set_handle_redirect( True ) 
br.set_handle_referer( True ) 
br.set_handle_robots( False ) 

# Refresh handle 
br.set_handle_refresh( mechanize._http.HTTPRefreshProcessor(), max_time = 1 ) 

br.addheaders = [ ( 'User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1' ) ] 

# authenticate 
br.open(chase_url) 
br.select_form( nr=0 ) 

br.form['UserID'] = 'joe1234'
br.form['Password'] = '123456'
br.submit() 

print "Success!\n"

sleep(10)

print br.title()