从域中提取第二级域名? - Python [英] Extract 2nd level domain from domain? - Python

查看:437
本文介绍了从域中提取第二级域名? - 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆