在我的python代码中,我向URL发出GET请求,我想知道最终转发的URL。 (获取request.history)
我已阅读-> Python Requests library redirect new url和http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history
我已经在下面成功完成了。当python获取GET URL时,如何确保禁用缓存?
response = requests.get(someurl)
if response.history:
print "Request was redirected"
for resp in response.history:
print resp.status_code, resp.url
print "Final destination:"
print response.status_code, response.url
else:
print "Request was not redirected"
如果我没记错的话,我必须使用标题
headers={'Cache-Control': 'no-cache'}
这是正确的吗?