python获取重定向的消息头的location??????????????

附件链接会发生跳转,想获取跳转后的下载链接,利用python爬取数据的。

import requests
url = 'http://home.cnblogs.com/u/xswt/'
r = requests.get(url,headers={"Content-Type":"application/json"})
reditList = r.history
print(f'获取重定向的历史记录:{reditList}')
print(f'获取第一次重定向的headers头部信息:{reditList[0].headers}')
print(f'获取重定向最终的url:{reditList[len(reditList)-1].headers["location"]}')



https://m.aliyun.com/yunqi/ziliao/4510

https://blog.csdn.net/qq_38609065/article/details/89452078