#导入requests包 import requests #会发生重定向的url url = "https://example.com" # 发送带有重定向的HTTP请求 response = requests.get(url, allow_redirects=True) # 获取最终重定向后的URL redirect_url = response .url #打印重定向链接 print(redirect_url )