SSL and POST with httplib or urllib

jsantaniello at my-deja.com jsantaniello at my-deja.com
Tue Jun 6 00:16:10 EDT 2000


The cgi (which I have no control over) returns a nice html page that
says it can't process my request because of a "format or context error".

A simple test html page I made:
<html>
<body>
<form method=POST action=https://www.experian.com/cgi-bin/ccredit.cgi>
<input type=hidden name=0 value=1>
<input type=SUBMIT>
</form>
</body>
</html>

works from a browser but:

import httplib
h = httplib.HTTPS('www.experian.com')
h.putrequest('POST', '/cgi-bin/ccredit.cgi?0=1')
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
print errcode # Should be 200
f = h.getfile()
print f.read()
f.close()

from a module returns a different page with the "context" error
business. And it's not a cookie issue.

Am I doing something wrong with specifiing POST? Is there a better way
to do that?

And if I try with urllib:

>>> import urllib
>>> params = urllib.urlencode({'0': 1})
>>> f = urllib.urlopen("https://www.experian.com/cgi-bin/ccredit.cgi",
params)

I get a traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python1.6/urllib.py", line 62, in urlopen
    return _urlopener.open(url, data)
  File "/usr/local/lib/python1.6/urllib.py", line 163, in open
    return getattr(self, name)(url, data)
TypeError: too many arguments; expected 2, got 3


Any ideas?

Thanks,

Joe



In article <etdog5fcx7a.fsf at w20-575-109.mit.edu>,
  Alex <cut_me_out at hotmail.com> wrote:
>
> What happens when you try to do a POST?
>
> Alex.
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list