Created
October 23, 2014 19:25
-
-
Save daryltucker/8cfd8502069f5e0b1027 to your computer and use it in GitHub Desktop.
Normalize URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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