How to get the domainname (name+TLD) from a URL in python

后端 未结 4 623
温柔的废话
温柔的废话 2021-01-14 04:51

I want to extract the domain name(name of the site+TLD) from a list of URLs which may vary in their format. for instance: Current state---->what I want

mai         


        
4条回答
  •  一向
    一向 (楼主)
    2021-01-14 05:15

    At this time I see six packages doing domain name splitting:

    • https://pypi.python.org/pypi/tldextract
    • https://pypi.python.org/pypi/tld
    • https://pypi.python.org/pypi/publicsuffixlist
    • https://pypi.python.org/pypi/publicsuffix
    • https://pypi.python.org/pypi/publicsuffix2
    • https://pypi.python.org/pypi/dnspy

    They differ in the way they cache Public Suffix List data (only tldextract uses a JSON file, thereby sparing to parse the list on loading), in the strategy used to download that data, and in the structure they keep in memory (respectively: frozenset, set, set, dictionaries of labels, ditto, dictionary of names) which determines the search algorithm.

提交回复
热议问题