📜  Requests-处理历史记录

📅  最后修改于: 2020-10-21 08:34:24             🧑  作者: Mango


 

您可以使用response.history获取给定URL的历史记录。如果给定的URL具有任何重定向,则将其存储在历史记录中。

对于历史

import requests
getdata = requests.get('http://google.com/')
print(getdata.status_code)
print(getdata.history)  

输出

E:\prequests>python makeRequest.py
200
[]

response.history属性将包含根据请求完成的响应对象的详细信息。当前值将按从旧到新的顺序排序。 response.history属性跟踪在请求的URL上完成的所有重定向。