脚本宝典收集整理的这篇文章主要介绍了php – 根据公共后缀列表从URL中提取注册域,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
例如,考虑a.bg是一个有效的公共后缀:
http://www.test.start.a.bg/hello.htML -> start.a.bg http://test.start.a.bg/ -> start.a.bg http://test.start.abc.bg/ -> abc.bg (.bg is the public suffix)
这不能使用简单的字符串操作来完成,因为根据TLD,公共后缀可以由多个级别组成.
require_once("effectiveTLDs.inc.PHP"); require_once("regDomain.inc.PHP"); $url = 'http://www.metu.edu.tr/dhasjkdas/sadsdds/sdda/sdads.html'; echo getRegisteredDomain(parse_url($url,PHP_URL_HOST));
这将打印出metu.edu.tr.
我试过的其他例子
http://www.xyz.start.bg/hello -> start.bg http://www.start.a.bg/world -> start.a.bg (a.bg is a listed eTLD) http://xyz.ma219.metu.edu.tr -> metu.edu.tr http://www.GOOGLE.COM/seArch -> google.com http://google.co.uk/search?asd -> google.co.uk
更新:这些库已被移动到:https://github.com/leth/registered-domains-php
以上是脚本宝典为你收集整理的php – 根据公共后缀列表从URL中提取注册域全部内容,希望文章能够帮你解决php – 根据公共后缀列表从URL中提取注册域所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。