Mtra
Mtra

Reputation: 201

Get date/time for request history

I have the below script which pulls all URL redirect history. Is there a way I can get the date and time of when these redirects were effected?

r = requests.get(url)
for h in r.history:
    print (h.url)
print (r.url)

Upvotes: 2

Views: 403

Answers (1)

Ram
Ram

Reputation: 541

You can get from the headers of the history objs. like.

r = requests.get(url)
for h in r.history:
    print (h.url)
    print (h.headers.get("date"))
print (r.url)

Upvotes: 4

Related Questions