Skip to content

Instantly share code, notes, and snippets.

@hrbrmstr
Created January 5, 2014 23:47
Show Gist options
  • Save hrbrmstr/8275775 to your computer and use it in GitHub Desktop.
Save hrbrmstr/8275775 to your computer and use it in GitHub Desktop.
script to process a file of hosts/domains into just TLDs using tldextract
#!/usr/bin/python
import tldextract
f = open("/tmp/indomains.txt")
hosts = f.readlines()
f.close()
tlds = ['.'.join(tldextract.extract(host.rstrip())[-2 : ]) for host in hosts]
f = open("/tmp/outdomains.txt","w")
f.writelines( "%s\n" % tld for tld in tlds )
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment