url="https://www.baidu.com/" url='http://www.freebuf.com/fevents/133225.html' # 方法一:禁止跳转:allow_redirects=False # 发请求,得响应 response = requests.get(url, headers=headers, allow_redirects=False) # 返回状态码 print(response.status_code) # 方法二:对比前后url print(url) print(response.url)