domainutils aims to provide different domain parsing tools in one place.
TLDParserTree builds a Trie like tree from the list of publicsuffix
TLDParserTree provides method split_tld
(alias s
) to separate TLD from a given domain such as en.wikipedia.com
will return a 2-tuple ('en.wikipedia', 'com')
.
>>> from domainutils.tld_parser import TLDParserTree
>>> tld_tree = TLDParserTree()
>>> tld_tree.s('google.com')
('google', 'com')
>>> tld_tree.s('nestle.com.bd')
('nestle', 'com.bd')
Run tests by simply running the domainutils/tests.py
$ python3.6 domainutils/tests.py
Please create an issue for bugs and feature requests.