擅长:python、mysql、java
<p>下面是一个很好的python模块,有人在看到这个问题后编写了这个模块来解决这个问题:
<a href="https://github.com/john-kurkowski/tldextract">https://github.com/john-kurkowski/tldextract</a></p>
<p>模块在<a href="https://www.publicsuffix.org/">Public Suffix List</a>中查找tld,由Mozilla志愿者覆盖</p>
<p>引用:</p>
<blockquote>
<p><code>tldextract</code> on the other hand knows what all gTLDs [<em>Generic Top-Level Domains</em>]
and ccTLDs [<em>Country Code Top-Level Domains</em>] look like
by looking up the currently living ones according to the <a href="https://www.publicsuffix.org/">Public Suffix
List</a>. So, given a URL, it knows its subdomain from its domain, and its
domain from its country code.</p>
</blockquote>