从域中提取第二级域名? - Python [英] Extract 2nd level domain from domain? - Python
问题描述
我有一个列表,例如
-
site.co.uk
site.co.uk
site.com
site.me.uk
site.me.uk
site.jpn.com
site.jpn.com
site.org.uk
site.org.uk
site.it
域名也可以包含第三和第四级域名
-
test.example.site.org.uk
test.example.site.org.uk
test2.site.com
test2.site.com
我需要尝试提取第二级在所有这些情况下都是网站
I need to try and extract the 2nd level domain, in all these cases being site
任何想法? :)
推荐答案
没有办法可靠地得到这个。子域是任意的,每天都有一个域扩展名的怪物列表。最好的情况是您检查域扩展的怪物列表并维护列表。
no way to reliably get that. Subdomains are arbitrary and there is a monster list of domain extensions that grows every day. Best case is you check against the monster list of domain extensions and maintain the list.
列表:
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1
这篇关于从域中提取第二级域名? - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!