English 中文(简体)
Requests - Handling History
  • 时间:2024-11-03

Requests - Handpng History


Previous Page Next Page  

You can get the history of a given URL by using response.history. If the given URL has any redirects, the same will be stored in history.

For history


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

Output


E:prequests>python makeRequest.py
200
[<Response [301]>]

The response.history property will have the details of the response objects that were done based on the request. The values present will be sorted from the oldest to the newest ones. The response.history property tracks all the redirection done on the URL requested.

Advertisements