How do I prevent Python’s urllib(2) from following a redirect
You could do a couple of things: Build your own HTTPRedirectHandler that intercepts each redirect Create an instance of HTTPCookieProcessor and install that opener so that you have access to the cookiejar. This is a quick little thing that shows both import urllib2 #redirect_handler = urllib2.HTTPRedirectHandler() class MyHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): … Read more