Reputation: 33
I want to test if the website status and return the requested time and response code at the same time.
requests.head('http://www.google.com').elapsed.total_seconds()
this code just return the requested time
requests.head('http://www.google.com').elapsed.total_seconds()
i want get the response code like 200 or 404, and the requested time.
Upvotes: 0
Views: 106
Reputation: 11925
In order to get the response code, and the total elapsed time, you can do this:
f = requests.head('http://www.google.com')
Now to see the response code you can just look at f.status_code
and to see the time, use f.elapsed.total_seconds()
Upvotes: 2