Sometimes the URL that we are accessing may have been moved or it might get redirected to some other location. We can track them using Requests. The response object's history property can be used to track the redirection. Requests can accomplish location redirection with every verb except with HEAD. The
Response.history list contains the objects of the Requests that were generated in order to complete the request.
>>> r = requests.get('http:google.com') >>> r.url u'http://www.google.co.in/?gfe_rd=cr&ei=rgMSVOjiFKnV8ge37YGgCA' >>> r.status_code 200 >>> r.history (<Response >,)
In the preceding example, when we tried sending a request to
'www.google.com', we got the
r.history value as ...