我正在尝试使用python mechanize
登录我的股票经纪人网站。我已成功登录,但mechanize
未重定向到主页面。
我想访问网址:https://secure.icicidirect.com/NewSiteTrading/trading/equity/Trading.asp
但mechanize
停在网址:https://secure.icicidirect.com/NewSiteTrading/customer/validlogon.asp?nFile=tradehome
import mechanize
br = mechanize.Browser()
url = 'https://secure.icicidirect.com/NewSiteTrading/customer/logon.asp'
br.set_handle_redirect(True)
br.set_debug_http(True)
br.set_debug_redirects(True)
br.open(url)
for form in br.forms():
print form
br.select_form(nr=3)
br.form['FML_USR_ID'] = 'username'
br.form['FML_USR_USR_PSSWRD'] = 'password'
br.form['FML_USR_DT_BRTH'] = 'dateofbirth'
br.submit()
br.geturl()
答案 0 :(得分:0)
登录后,只需在同一个机械化会话中打开主页:
br.open('https://secure.icicidirect.com/NewSiteTrading/trading/equity/Trading.asp')