Is there an easy way to request a URL in python and NOT follow redirects?

Here is the Requests way:

import requests
r = requests.get('http://github.com', allow_redirects=False)
print(r.status_code, r.headers['Location'])

Leave a Comment