import requests
url = 'http://xhslink.com/oSVbN'
headers = {
'User-Agent': 'Mozilla/5.0'
}
response = requests.get(url=url, headers=headers, allow_redirects=False)
注:allow_redirects=False 禁止重定向
allow_redirects 默认为true, requets库自动处理了重定向请求
print(response.status_code)
print(response.text)
print(response.headers['Location'])
运行结果如下: