En Wed, 07 Jan 2009 09:27:00 -0200, Gilles Ganault <nos...@nospam.com> escribió:

I'm using urllib2 to connect to a web server with POST, and then the
server sends a cookie to hold the session ID, but also redirects the
user to another page:

If you're still interested, the way to avoid a redirect would be to use a RedirectHandler that does nothing:

from urllib2 import HTTPRedirectHandler, build_opener

class AvoidRedirectHandler(HTTPRedirectHandler):
    def http_error_302(self, req, fp, code, msg, headers): pass
    http_error_301 = http_error_303 = http_error_307 = http_error_302

opener = build_opener(AvoidRedirectHandler)
opener.open(url, data)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to