python接口自動化測試九:重定向相關
allow_redirects=False 不重定向
# 獲取重定向后的地址
loc = r.headers

# 相對地址
host = 'https://i.cnblogs.com/'
url = host+'EditPosts.aspx?opt=1'
loc = r.headers['Location']
url1 = host+loc # 拼接出重定向后的地址

# 追蹤重定向過程
his = r.history
print(type(his))
print(his)
# 追蹤第二個請求內容
r2 = his[1]
print(r2)

# 通過Response對象,來獲取返回內容
print(r2.url)
print(r2.status_code)
print(r2.headers)
print(r2.test)

