Skip to content

Instantly share code, notes, and snippets.

@mahmoudhossam
Created May 1, 2014 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoudhossam/ff6221e1f77c7adf4563 to your computer and use it in GitHub Desktop.
Save mahmoudhossam/ff6221e1f77c7adf4563 to your computer and use it in GitHub Desktop.
Unshortens URLs
import requests
def unshorten(url):
try:
r = requests.head(url, allow_redirects=True)
except:
return r.url
return r.url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment