
- Requests Tutorial
- Requests - Home
- Requests - Overview
- Requests - Environment Setup
- Requests - How Http Requests Work?
- Requests - Working with Requests
- Handling Response for HTTP Requests
- Requests - HTTP Requests Headers
- Requests - Handling GET Requests
- Handling POST, PUT, PATCH & DELETE Requests
- Requests - File Upload
- Requests - Working with Cookies
- Requests - Working with Errors
- Requests - Handling Timeouts
- Requests - Handling Redirection
- Requests - Handling History
- Requests - Handling Sessions
- Requests - SSL Certification
- Requests - Authentication
- Requests - Event Hooks
- Requests - Proxy
- Requests - Web Scraping using Requests
- Requests Useful Resources
- Requests - Quick Guide
- Requests - Useful Resources
- Requests - Discussion
Requests - Handling History
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