Разница между String.indexOf (int x) и String.indexOf (String) [закрыто]

Вы ищете историю запросов .

Атрибут response.history - это список ответов, которые привели к окончательному URL-адресу, который можно найти в response.url .

response = requests.get(someurl)
if response.history:
    print "Request was redirected"
    for resp in response.history:
        print resp.status_code, resp.url
    print "Final destination:"
    print response.status_code, response.url
else:
    print "Request was not redirected"

Демонстрация:

>>> import requests
>>> response = requests.get('http://httpbin.org/redirect/3')
>>> response.history
(, , )
>>> for resp in response.history:
...     print resp.status_code, resp.url
... 
302 http://httpbin.org/redirect/3
302 http://httpbin.org/redirect/2
302 http://httpbin.org/redirect/1
>>> print response.status_code, response.url
200 http://httpbin.org/get

-8
задан Brad Mace 9 August 2013 в 05:30
поделиться