[Tutor] Firstrade Authentication ...

Kent Johnson kent37 at tds.net
Sun Aug 3 23:04:39 CEST 2008


On Sun, Aug 3, 2008 at 12:45 PM, Federo <federo at email.si> wrote:
> Jeff, Kent Hi!
>
> If possible I would most appreciate to use mechanize approach Jeff suggested.
> Python plagin: http://wwwsearch.sourceforge.net/mechanize/

This seems to get to the "Thank you for applying for a Firstrade account." page:
import urllib2
import urllib
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
f = opener.open('https://investor.firstrade.com/firstrade/login.do')
data = f.read()
f.close()

params = dict(username='janezfedero', password='kmet500', destination='')
params['login.x'] = 'Log+In'
params = urllib.urlencode(params)
f = opener.open('https://investor.firstrade.com/firstrade/login.do', params)
data = f.read()
f.close()
print(data)

Differences from your code:
- Does a GET on the login page - the session cookie is set here, not on the POST
- Includes all the form parameters

Kent

PS Please respond to the list, not to me personally.


More information about the Tutor mailing list