Last active
December 16, 2015 05:09
-
-
Save matthewrobertbell/5382717 to your computer and use it in GitHub Desktop.
Do you even code bro?
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 | |
import collections | |
def tree(): | |
return collections.defaultdict(tree) | |
urls = (l.strip() for l in open('urls.txt') if len(l.strip())) | |
data = tree() | |
for url in urls: | |
parsed = urlparse.urlparse(url) | |
data[parsed.path][parsed.netloc] = url | |
for path, urls in data.items(): | |
print path, urls.values() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment