Skip to content

Instantly share code, notes, and snippets.

@daryltucker
Created October 23, 2014 19:25
Show Gist options
  • Save daryltucker/8cfd8502069f5e0b1027 to your computer and use it in GitHub Desktop.
Save daryltucker/8cfd8502069f5e0b1027 to your computer and use it in GitHub Desktop.
Normalize URLs
import urlparse
def url_norm(url, scheme='http'):
response = 0
try:
x = urlparse.urlsplit(url, scheme=scheme)
response = '%s://%s%s' % (x.scheme, x.netloc, x.path)
except Exception:
pass
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment