请求网页后, requests 会自动帮我们重定向到最终页面
这时候会有一个 requests.history 属性
里面包含了所有重定向后的内容.(一个列表) 如果需要查看location 可以自行查看是第几个的location 直接拿出来就行了
例子
url = ‘test.com’
response = requests.get(url, headers=headers)
history_list = response.history
# 如果需要第一个301/302跳转的头信息
need_headers = history_list[0].headers