我有一个要获取的 url,它提供了 HTTP 303 重定向:
import urllib2 as web
import sys
url='http://sample.com'
try: handle=web.urlopen(url)
except web.HTTPError, e:
print e.code
sys.exit(1)
data=handle.read()
print 'Result :'
print data
因此,上面的代码打印303
结果是 303 重定向。
我希望它应该遵循重定向并为我获取目标的 HTML。
请帮忙..
编辑 :
curl -I http://my303redirecturl.com/
HTTP/1.1 303 See Other
Date: Tue, 23 Aug 2011 04:53:53 IST
Server: Mule Core/3.1.2
Expires: Tue, 23 Aug 2011 04:53:53 IST
http.status: 303
Content-Type: application/json
MULE_ENCODING: UTF-8
Content-Length: 0
Connection: close
这会有帮助吗?