[Tutor] Firstrade Authentication: Form Management
Federo
federo at email.si
Sat Aug 9 17:57:14 CEST 2008
Kent hi
I do hope we are now close to the final solution. I have used Firefox plagin
TamperData as you suggested and concequently amanded the code. Header Fields
are know clear (you can see them in the attached file). There is some problem
with Python code:
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='kmet555', 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)
#params2 = dict(contentProvider='pinnacor', quoteSymbol='goog',
optionChain='goog', countryCode='US', optionRange='NTM', tickerSymbol='goog',
ContentType='stockQuote')
params2['contentProvider'] = 'pinnacor'
params2['quoteSymbol'] = 'goog'
params2['optionChain'] = 'goog'
params2['countryCode'] = 'US'
params2['optionRange'] = 'NTM'
params2['tickerSymbol'] = 'goog'
params2['contentType'] = 'stockQuote'
params2['quote.x'] = 'submitted'
f = opener.open('https://investor.firstrade.com/firstrade/mainmenu.do', params2)
data2 = f.read()
f.close()
print(data2)
Error Message:
File "C:\Python25\lib\urllib2.py", line 381, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 399, in _open
'_open', req)
File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1115, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python25\lib\urllib2.py", line 1079, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "C:\Python25\lib\httplib.py", line 866, in request
self._send_request(method, url, body, headers)
File "C:\Python25\lib\httplib.py", line 892, in _send_request
self.send(body)
File "C:\Python25\lib\httplib.py", line 711, in send
self.sock.sendall(str)
File "C:\Python25\lib\httplib.py", line 1108, in send
return self._ssl.write(stuff)
TypeError: write() argument 1 must be string or read-only buffer, not dict
Cheers, Fedo
On Fri, 8 Aug 2008 at 13:56:29, Kent Johnson wrote:
> On Fri, Aug 8, 2008 at 5:12 AM, Federo <federo at email.si> wrote:
> > Kent hi
> >
> > I am still unable to enter data into textbox and getting back server reply.
> The
> > main problem is that I do not understand which fileds / header to observer
> > using Firefox Fireburg. Atteched you can see headers I went through. With
> red
> > font I marked differences among stages. In nider of the headers I didn't
> find
> > fieldds you included in your workable login code.
>
> Hi Federo,
>
> This isn't really a Python question anymore, it is a matter of
> figuring out what the server requires. You have to look at the form
> data as well as the headers. TamperData is one Firefox pluging that
> can do that, I'm sure there are others as well.
>
> Kent
____________________
http://www.email.si/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FormManagement_VPR.doc
Type: application/octet-stream
Size: 146944 bytes
Desc: FormManagement_VPR.doc
URL: <http://mail.python.org/pipermail/tutor/attachments/20080809/fe3e705b/attachment-0001.obj>
More information about the Tutor
mailing list