S
Sriram Krishnan
I've just downloaded the alpha of Python 2.4 and I'm not able to get
HTTP Redirection to work - even the examples are failing for me. They
all give the same error message (whenever a site issues a HTTP 302)
import urllib2
thing = urllib2.HTTPRedirectHandler()
opener = urllib2.build_opener(thing)
url = 'http://www.msdn.com'
page = opener.open(url)
Traceback (most recent call last):
File "test.py", line 11, in ?
f = urllib2.urlopen('http://www.msdn.com/')
File "D:\Python24\lib\urllib2.py", line 131, in urlopen
return _opener.open(url, data)
File "D:\Python24\lib\urllib2.py", line 359, in open
response = self._open(req, data)
File "D:\Python24\lib\urllib2.py", line 377, in _open
'_open', req)
File "D:\Python24\lib\urllib2.py", line 338, in _call_cha
result = func(*args)
File "D:\Python24\lib\urllib2.py", line 1014, in http_ope
return self.do_open(httplib.HTTPConnection, req)
File "D:\Python24\lib\urllib2.py", line 1008, in do_open
r.msg.dict)
File "D:\Python24\lib\urllib2.py", line 397, in error
result = self._call_chain(*args)
File "D:\Python24\lib\urllib2.py", line 338, in _call_cha
result = func(*args)
File "D:\Python24\lib\urllib2.py", line 524, in http_erro
newurl = headers.getheaders('location')[0]
AttributeError: 'dict' object has no attribute 'getheaders'
Am I making a newbie error here? Or am I missing something?
Sriram
HTTP Redirection to work - even the examples are failing for me. They
all give the same error message (whenever a site issues a HTTP 302)
import urllib2
thing = urllib2.HTTPRedirectHandler()
opener = urllib2.build_opener(thing)
url = 'http://www.msdn.com'
page = opener.open(url)
Traceback (most recent call last):
File "test.py", line 11, in ?
f = urllib2.urlopen('http://www.msdn.com/')
File "D:\Python24\lib\urllib2.py", line 131, in urlopen
return _opener.open(url, data)
File "D:\Python24\lib\urllib2.py", line 359, in open
response = self._open(req, data)
File "D:\Python24\lib\urllib2.py", line 377, in _open
'_open', req)
File "D:\Python24\lib\urllib2.py", line 338, in _call_cha
result = func(*args)
File "D:\Python24\lib\urllib2.py", line 1014, in http_ope
return self.do_open(httplib.HTTPConnection, req)
File "D:\Python24\lib\urllib2.py", line 1008, in do_open
r.msg.dict)
File "D:\Python24\lib\urllib2.py", line 397, in error
result = self._call_chain(*args)
File "D:\Python24\lib\urllib2.py", line 338, in _call_cha
result = func(*args)
File "D:\Python24\lib\urllib2.py", line 524, in http_erro
newurl = headers.getheaders('location')[0]
AttributeError: 'dict' object has no attribute 'getheaders'
Am I making a newbie error here? Or am I missing something?
Sriram