Skip to content

Instantly share code, notes, and snippets.

@tylerdave
Created August 14, 2013 03:34

Revisions

  1. tylerdave created this gist Aug 14, 2013.
    7 changes: 7 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import requests

    def _resolve_redirected_url(url):
    response = requests.get(url, allow_redirects=False)
    if response.status_code in [301, 302, 307, 308] and 'location' in response.headers:
    url = response.headers['location']
    return url