php查詢whois信息的方法
本文實(shí)例講述了php查詢whois信息的方法。分享給大家供大家參考。具體如下:
這里使用php通過(guò)查詢whois信息的網(wǎng)站列表進(jìn)行查詢
function whois_query($domain) {
// fix the domain name:
$domain = strtolower(trim($domain));
$domain = preg_replace('/^http:\/\//i', '', $domain);
$domain = preg_replace('/^www\./i', '', $domain);
$domain = explode('/', $domain);
$domain = trim($domain[0]);
// split the TLD from domain name
$_domain = explode('.', $domain);
$lst = count($_domain)-1;
$ext = $_domain[$lst];
// You find resources and lists
// like these on wikipedia:
//
// http://de.wikipedia.org/wiki/Whois
//
$servers = array(
"biz" => "whois.neulevel.biz",
"com" => "whois.internic.net",
"us" => "whois.nic.us",
"coop" => "whois.nic.coop",
"info" => "whois.nic.info",
"name" => "whois.nic.name",
"net" => "whois.internic.net",
"gov" => "whois.nic.gov",
"edu" => "whois.internic.net",
"mil" => "rs.internic.net",
"int" => "whois.iana.org",
"ac" => "whois.nic.ac",
"ae" => "whois.uaenic.ae",
"at" => "whois.ripe.net",
"au" => "whois.aunic.net",
"be" => "whois.dns.be",
"bg" => "whois.ripe.net",
"br" => "whois.registro.br",
"bz" => "whois.belizenic.bz",
"ca" => "whois.cira.ca",
"cc" => "whois.nic.cc",
"ch" => "whois.nic.ch",
"cl" => "whois.nic.cl",
"cn" => "whois.cnnic.net.cn",
"cz" => "whois.nic.cz",
"de" => "whois.nic.de",
"fr" => "whois.nic.fr",
"hu" => "whois.nic.hu",
"ie" => "whois.domainregistry.ie",
"il" => "whois.isoc.org.il",
"in" => "whois.ncst.ernet.in",
"ir" => "whois.nic.ir",
"mc" => "whois.ripe.net",
"to" => "whois.tonic.to",
"tv" => "whois.tv",
"ru" => "whois.ripn.net",
"org" => "whois.pir.org",
"aero" => "whois.information.aero",
"nl" => "whois.domain-registry.nl"
);
if (!isset($servers[$ext])){
die('Error: No matching nic server found!');
}
$nic_server = $servers[$ext];
$output = '';
// connect to whois server:
if ($conn = fsockopen ($nic_server, 43)) {
fputs($conn, $domain."\r\n");
while(!feof($conn)) {
$output .= fgets($conn,128);
}
fclose($conn);
}
else { die('Error: Could not connect to ' . $nic_server . '!'); }
return $output;
}
// Some example queries:
print whois_query('jonasjohn.de');
print whois_query('example.com');
print whois_query('example.org');
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
- php whois查詢API制作方法
- 用PHP查詢域名狀態(tài)whois的類(lèi)
- PHP實(shí)現(xiàn)域名whois查詢的代碼(數(shù)據(jù)源萬(wàn)網(wǎng)、新網(wǎng))
- 用PHP實(shí)現(xiàn)標(biāo)準(zhǔn)的IP Whois查詢
- PHP Socket網(wǎng)絡(luò)操作類(lèi)定義與用法示例
- PHP+Ajax 檢測(cè)網(wǎng)絡(luò)是否正常實(shí)例詳解
- php判斷是否連接上網(wǎng)絡(luò)的方法實(shí)例詳解
- PHP使用CURL實(shí)現(xiàn)對(duì)帶有驗(yàn)證碼的網(wǎng)站進(jìn)行模擬登錄的方法
- 使用PHP curl模擬瀏覽器抓取網(wǎng)站信息
- PHP whois查詢類(lèi)定義與用法示例
相關(guān)文章
PHP實(shí)現(xiàn)動(dòng)態(tài)添加X(jué)ML中數(shù)據(jù)的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)動(dòng)態(tài)添加X(jué)ML中數(shù)據(jù)的方法,結(jié)合實(shí)例形式分析了php操作xml格式數(shù)據(jù)類(lèi)的定義及簡(jiǎn)單使用技巧,需要的朋友可以參考下2018-03-03
PHP面向?qū)ο蟪绦蛟O(shè)計(jì)之對(duì)象克隆clone和魔術(shù)方法__clone()用法分析
這篇文章主要介紹了PHP面向?qū)ο蟪绦蛟O(shè)計(jì)之對(duì)象克隆clone和魔術(shù)方法__clone()用法,結(jié)合具體實(shí)例形式分析了php面向?qū)ο蟪绦蛟O(shè)計(jì)中對(duì)象克隆clone和魔術(shù)方法__clone()相關(guān)操作技巧與使用注意事項(xiàng),需要的朋友可以參考下2019-06-06
header中Content-Disposition的作用與使用方法
本文章詳細(xì)的介紹了關(guān)于php header中Content-disposition用法詳細(xì),有需要了解header用法的朋友可參考一下2012-06-06
php實(shí)現(xiàn)在新浪云中使用imagick生成縮略圖并上傳的方法
這篇文章主要介紹了php實(shí)現(xiàn)在新浪云中使用imagick生成縮略圖并上傳的方法,涉及新浪云SaeStorage類(lèi)的相關(guān)操作技巧,需要的朋友可以參考下2016-09-09
PHP+JS實(shí)現(xiàn)批量刪除數(shù)據(jù)功能示例
這篇文章主要介紹了PHP+JS實(shí)現(xiàn)批量刪除數(shù)據(jù)功能,結(jié)合實(shí)例形式分析了php結(jié)合js控制頁(yè)面元素的選中與提交,以及php操作mysql實(shí)現(xiàn)批量刪除功能的相關(guān)實(shí)現(xiàn)技巧,末尾還附帶了一個(gè)php數(shù)據(jù)庫(kù)操作類(lèi),需要的朋友可以參考下2017-11-11

