background image

php 函数:域名 whois 查询功能实现

函数一:
<?php
//

 

万网 whois(使用的接口为万网提供合法接口)

function whois_hichina($domain) {
preg_match(“|<pre>(.

 

?)</pre>|is”, 

@file_get_contents(‘http://whois.hichina.com/cgi-bin/whois?domain=’.
$domain.”), $whois);
$whois[0] = str_replace(‘友情提示:按注册局要求,过期域名可能会处于注册商自动
续 费 期 阶 段 , 您 在 此 查 询 所 看 到 的 域 名 到 期 日 仅 供 参 考 <br   /> 请 您 <a 
href=”http://www.net.cn/has_client/userlogon/user_logon1.asp” 
target=”_blank” class=”link_gl”>进入会员区</a>查看该域名的实际到期时间,并

请及时进行续费,谢谢! , ”, ($whois[0]));//过滤掉此段文字
return $whois[0];
}
//函数调用
echo whois_hichina(‘www.baidu.com’)
函数二:
//

 

新网 whois (非新网提供,只是根据新网自身网站的 url 修改实现)

function whois_xinnet($domain) {
preg_match(“|<div

 

class=\”lyTableInfoWrap\”>(.

 

?)</div>|is”, 

@file_get_contents(        ’http://www.xinnet.cn/Modules/agent/serv/pages/dom
ain_whois.jsp?domainNameWhois=’.$domain.’&noCode=noCode’), $whois);
return $whois[0];
}
//函数调用
echo whois_xinnet(‘www.baidu.com’)
?>

标签:php, whois, 接口