php whois查詢API制作方法
更新時(shí)間:2011年06月23日 22:13:51 作者:
網(wǎng)站們經(jīng)常需要查詢網(wǎng)站whois信息,這里介紹一個(gè)使用php制作的whois api接口,方法也很簡單,下面詳細(xì)介紹一下。
這里我們從萬網(wǎng)或新網(wǎng)的數(shù)據(jù)接口取得數(shù)據(jù),透過php的簡單文本處理再輸出。
<php?
$domain = $_GET['q'];
preg_match("|
<div class="\"lyTableInfoWrap\"">(.+?)</div>
|is", @file_get_contents('http://www.xinnet.cn/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);
echo $whois[1];
?>
做到這里,可能有的朋友要問了,這不就是簡單的php腳本么?!哪是api接口阿;接著我們來加工一下,讓查詢方式更專業(yè)一些:
我們需要的查詢格式如下:
http://api/whois/baidu.com
其中baidu.com是需要查詢的域名
可以修改nginx的配置來實(shí)現(xiàn)這一點(diǎn):
location ~* /whois/(.+)$ {
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu.com
#將查詢傳遞給內(nèi)網(wǎng)的apache處理
}
ok,至此一個(gè)使用的whois api接口完成了,你可以自己的程序中調(diào)用,也可以共享給大家使用^_^!。
查詢baidu.com的結(jié)果:
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: BAIDU.COM
Registrar: REGISTER.COM, INC.
Whois Server: whois.register.com
Referral URL: http://www.register.com
Name Server: DNS.BAIDU.COM
Name Server: NS2.BAIDU.COM
Name Server: NS3.BAIDU.COM
Name Server: NS4.BAIDU.COM
Status: clientTransferProhibited
Status: serverDeleteProhibited
Status: serverTransferProhibited
Status: serverUpdateProhibited
Updated Date: 15-mar-2010
Creation Date: 11-oct-1999
Expiration Date: 11-oct-2014
>>> Last update of whois database: Fri, 20 Aug 2010 05:42:12 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' (“VeriSign”) Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.
The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
The data in Register.com's WHOIS database is provided to you by
Register.com for information purposes only, that is, to assist you in
obtaining information about or related to a domain name registration
record. Register.com makes this information available “as is,” and
does not guarantee its accuracy. By submitting a WHOIS query, you
agree that you will use this data only for lawful purposes and that,
under no circumstances will you use this data to: (1) allow, enable,
or otherwise support the transmission of mass unsolicited, commercial
advertising or solicitations via direct mail, electronic mail, or by
telephone; or (2) enable high volume, automated, electronic processes
that apply to Register.com (or its systems). The compilation,
repackaging, dissemination or other use of this data is expressly
prohibited without the prior written consent of Register.com.
Register.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by these terms.
Registrant:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059926680
Email: domainmaster@baidu.com
Registrar Name….: Register.com
Registrar Whois…: whois.register.com
Registrar Homepage: www.register.com
Domain Name: baidu.com
Created on…………..: 1999-10-11
Expires on…………..: 2014-10-11
Administrative Contact:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059927440
Email: wumengyi@baidu.com
Technical Contact:
Registercom
Domain Registrar
575 8th Avenue
New York, NY 10018
US
Phone: +1.9027492701
Email: domainregistrar@register.com
DNS Servers:
ns3.baidu.com
ns2.baidu.com
ns4.baidu.com
dns.baidu.com
Visit AboutUs.org for more information about baidu.com
AboutUs: baidu.com
Register your domain name at http://www.register.com
復(fù)制代碼 代碼如下:
<php?
$domain = $_GET['q'];
preg_match("|
<div class="\"lyTableInfoWrap\"">(.+?)</div>
|is", @file_get_contents('http://www.xinnet.cn/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);
echo $whois[1];
?>
做到這里,可能有的朋友要問了,這不就是簡單的php腳本么?!哪是api接口阿;接著我們來加工一下,讓查詢方式更專業(yè)一些:
我們需要的查詢格式如下:
http://api/whois/baidu.com
其中baidu.com是需要查詢的域名
可以修改nginx的配置來實(shí)現(xiàn)這一點(diǎn):
復(fù)制代碼 代碼如下:
location ~* /whois/(.+)$ {
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu.com
#將查詢傳遞給內(nèi)網(wǎng)的apache處理
}
ok,至此一個(gè)使用的whois api接口完成了,你可以自己的程序中調(diào)用,也可以共享給大家使用^_^!。
查詢baidu.com的結(jié)果:
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: BAIDU.COM
Registrar: REGISTER.COM, INC.
Whois Server: whois.register.com
Referral URL: http://www.register.com
Name Server: DNS.BAIDU.COM
Name Server: NS2.BAIDU.COM
Name Server: NS3.BAIDU.COM
Name Server: NS4.BAIDU.COM
Status: clientTransferProhibited
Status: serverDeleteProhibited
Status: serverTransferProhibited
Status: serverUpdateProhibited
Updated Date: 15-mar-2010
Creation Date: 11-oct-1999
Expiration Date: 11-oct-2014
>>> Last update of whois database: Fri, 20 Aug 2010 05:42:12 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' (“VeriSign”) Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.
The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
The data in Register.com's WHOIS database is provided to you by
Register.com for information purposes only, that is, to assist you in
obtaining information about or related to a domain name registration
record. Register.com makes this information available “as is,” and
does not guarantee its accuracy. By submitting a WHOIS query, you
agree that you will use this data only for lawful purposes and that,
under no circumstances will you use this data to: (1) allow, enable,
or otherwise support the transmission of mass unsolicited, commercial
advertising or solicitations via direct mail, electronic mail, or by
telephone; or (2) enable high volume, automated, electronic processes
that apply to Register.com (or its systems). The compilation,
repackaging, dissemination or other use of this data is expressly
prohibited without the prior written consent of Register.com.
Register.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by these terms.
Registrant:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059926680
Email: domainmaster@baidu.com
Registrar Name….: Register.com
Registrar Whois…: whois.register.com
Registrar Homepage: www.register.com
Domain Name: baidu.com
Created on…………..: 1999-10-11
Expires on…………..: 2014-10-11
Administrative Contact:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059927440
Email: wumengyi@baidu.com
Technical Contact:
Registercom
Domain Registrar
575 8th Avenue
New York, NY 10018
US
Phone: +1.9027492701
Email: domainregistrar@register.com
DNS Servers:
ns3.baidu.com
ns2.baidu.com
ns4.baidu.com
dns.baidu.com
Visit AboutUs.org for more information about baidu.com
AboutUs: baidu.com
Register your domain name at http://www.register.com
您可能感興趣的文章:
- 用PHP查詢域名狀態(tài)whois的類
- PHP實(shí)現(xiàn)域名whois查詢的代碼(數(shù)據(jù)源萬網(wǎng)、新網(wǎng))
- php查詢whois信息的方法
- 用PHP實(shí)現(xiàn)標(biāo)準(zhǔn)的IP Whois查詢
- PHP Socket網(wǎng)絡(luò)操作類定義與用法示例
- PHP+Ajax 檢測網(wǎng)絡(luò)是否正常實(shí)例詳解
- php判斷是否連接上網(wǎng)絡(luò)的方法實(shí)例詳解
- PHP使用CURL實(shí)現(xiàn)對帶有驗(yàn)證碼的網(wǎng)站進(jìn)行模擬登錄的方法
- 使用PHP curl模擬瀏覽器抓取網(wǎng)站信息
- PHP whois查詢類定義與用法示例
相關(guān)文章
php mssql擴(kuò)展SQL查詢中文字段名解決方法
問題就出現(xiàn)在SQLServer中表的字段名是中文,寫好的查詢語句在SQLServe里測試是通過有記錄返回,用PHP的MSSQL擴(kuò)展查詢就是報(bào)錯(cuò)2012-10-10
php+Ajax無刷新驗(yàn)證用戶名操作實(shí)例詳解
這篇文章主要介紹了php+Ajax無刷新驗(yàn)證用戶名操作,簡單介紹了ajax的原理并結(jié)合實(shí)例形式分析了php結(jié)合ajax無刷新驗(yàn)證用戶名相關(guān)操作技巧,需要的朋友可以參考下2019-03-03
PHP基于PDO擴(kuò)展操作mysql數(shù)據(jù)庫示例
這篇文章主要介紹了PHP基于PDO擴(kuò)展操作mysql數(shù)據(jù)庫,結(jié)合實(shí)例形式分析了php使用pdo擴(kuò)展針對mysql數(shù)據(jù)庫的查詢、插入、修改等操作實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-12-12
php實(shí)現(xiàn)的讀取CSV文件函數(shù)示例
這篇文章主要介紹了php實(shí)現(xiàn)的讀取CSV文件函數(shù),結(jié)合實(shí)例形式分析了php讀取CSV文件及字符串、數(shù)組遍歷與轉(zhuǎn)換等操作技巧,需要的朋友可以參考下2017-02-02
PHP模擬登陸163郵箱發(fā)郵件及獲取通訊錄列表的方法
這篇文章主要介紹了PHP模擬登陸163郵箱發(fā)郵件及獲取通訊錄列表的方法,實(shí)例分析了php實(shí)用curl模擬登陸163郵箱的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
PHP計(jì)劃任務(wù)、定時(shí)執(zhí)行任務(wù)的實(shí)現(xiàn)代碼
PHP計(jì)劃任務(wù)、定時(shí)執(zhí)行任務(wù)的實(shí)現(xiàn)用到的函數(shù) ignore_user_abort(),set_time_limit(0),sleep($interval) 此代碼只要運(yùn)行一次后關(guān)閉瀏覽器即可。2011-04-04

