url = 'http://httpbin.org/redirect/5'
session = requests.session()
r = session.get(url, allow_redirects=False)
r.headers.get('location')
How to avoid / prevent Max Redirects error with requests in Python?