http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history
官方文档早有提及。这种跳转一般是301/302跳转,判断一下http状态码之后,在history属性可以记录跳转的路径。
另外,还有以下这样的get属性,可以不自动跟随URL跳转
allow_redirects=False
哈泥湖:
我是模拟登陆weibo.cn,post了相关参数后,发现有3个重定向(状态码是302),每个跳转的url都是在header里的location中,在firebug里头可以看到header的location值,但是用requests取header的时候没有location值,一直没有弄通
4年前
回复