Python获取301跳转的地址

通过浏览器F12可以从headers里看到location跳转的地址。

通过抓包也可以找到headers中的location地址。

这篇博文使用Python Requests模块来找到301跳转的地址。

先上代码:

#python代码
import requests
r = requests.get('http://7aweb.com',allow_redirects=False)
print(r.headers['Location'])

allow_redirects=False 禁止直接跳转。

如果设置过7aweb.com跳转到www.7aweb.com。将会返回http://www.7aweb.com

You May Also Like

About the Author: admin

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注