I must not be getting the point of this from the documentation.
I want to connect to a URL and see what it redirects to. I built
a redirect handler that does nothing much (for testing) and installed
it thusly:
import urllib2
class R(urllib2.HTTPR edirectHandler) :
def redirect_reques t(req,fp,code,m sg,hdrs):
print "%s, %s, %s, %s, %s" % (req,fp,code,ms g,hdrs)
raise urllib2.HTTPErr or
o = urllib2.build_o pener(R())
urllib2.install _opener(o)
f = urllib2.urlopen ('http://sony.com/walkmanreg')
print f.read()[:200]
but instead of printing the message from my redirect handler, it prints
out the text of the redirected-to URL.
Any help appreciated.
clarence@silcom .com
I want to connect to a URL and see what it redirects to. I built
a redirect handler that does nothing much (for testing) and installed
it thusly:
import urllib2
class R(urllib2.HTTPR edirectHandler) :
def redirect_reques t(req,fp,code,m sg,hdrs):
print "%s, %s, %s, %s, %s" % (req,fp,code,ms g,hdrs)
raise urllib2.HTTPErr or
o = urllib2.build_o pener(R())
urllib2.install _opener(o)
f = urllib2.urlopen ('http://sony.com/walkmanreg')
print f.read()[:200]
but instead of printing the message from my redirect handler, it prints
out the text of the redirected-to URL.
Any help appreciated.
clarence@silcom .com
Comment