php whois查询API制作方法


Posted in PHP onJune 23, 2011

这里我们从万网或新网的数据接口取得数据,透过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接口阿;接着我们来加工一下,让查询方式更专业一些:
我们需要的查询格式如下:
http://api/whois/baidu.com
其中baidu.com是需要查询的域名
可以修改nginx的配置来实现这一点:
location ~* /whois/(.+)$ { 
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu.com 
#将查询传递给内网的apache处理 
}

ok,至此一个使用的whois api接口完成了,你可以自己的程序中调用,也可以共享给大家使用^_^!。
查询baidu.com的结果:
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 相关文章推荐
php分页思路以及在ZF中的使用
May 30 PHP
php中将指针移动到数据集初始位置的实现代码[mysql_data_seek]
Nov 01 PHP
php 模拟POST提交的2种方法详解
Jun 17 PHP
php中curl、fsocket、file_get_content三个函数的使用比较
May 09 PHP
美图秀秀web开放平台--PHP流式上传和表单上传示例分享
Jun 22 PHP
php启用sphinx全文搜索的实现方法
Dec 24 PHP
php+mysqli实现将数据库中一张表信息打印到表格里的方法
Jan 28 PHP
php通过ksort()函数给关联数组按照键排序的方法
Mar 18 PHP
PHP实现微信网页授权开发教程
Jan 19 PHP
详解PHP处理字符串类似indexof的方法函数
Jun 11 PHP
PHP异常处理定义与使用方法分析
Jul 25 PHP
PHP实现腾讯与百度坐标转换
Aug 05 PHP
PHP字符编码问题之GB2312 VS UTF-8解决方法
Jun 23 #PHP
PHP读取网页文件内容的实现代码(fopen,curl等)
Jun 23 #PHP
php中获取指定IP的物理地址的代码(正则表达式)
Jun 23 #PHP
PHP学习笔记 (1) 环境配置与代码调试
Jun 19 #PHP
php开发过程中关于继承的使用方法分享
Jun 17 #PHP
php设计模式  Command(命令模式)
Jun 17 #PHP
php学习笔记 面向对象中[接口]与[多态性]的应用
Jun 16 #PHP
You might like
php环境配置 php5 mysql5 apache2 phpmyadmin安装与配置
2006/11/17 PHP
php 删除无限级目录与文件代码共享
2008/11/22 PHP
用PHP读取超大文件的实例代码
2012/04/01 PHP
解析:使用php mongodb扩展时 需要注意的事项
2013/06/18 PHP
两种设置php载入页面时编码的方法
2014/07/29 PHP
php批量添加数据与批量更新数据的实现方法
2014/12/16 PHP
golang、python、php、c++、c、java、Nodejs性能对比
2017/03/12 NodeJs
ThinkPHP5+Layui实现图片上传加预览功能
2018/08/17 PHP
js创建对象的几种常用方式小结(推荐)
2010/10/24 Javascript
探讨在JQuery和Js中,如何让ajax执行完后再继续往下执行
2013/07/09 Javascript
js中top的作用深入剖析
2014/03/04 Javascript
浅谈javascript中的闭包
2015/05/13 Javascript
javascript+canvas实现刮刮卡抽奖效果
2015/07/29 Javascript
js实现模拟银行卡账号输入显示效果
2015/11/18 Javascript
javascript实现PC网页里的拖拽效果
2016/03/14 Javascript
JS中使用变量保存arguments对象的方法
2016/06/03 Javascript
走进javascript——不起眼的基础,值和分号
2017/02/24 Javascript
纯js的右下角弹窗实例
2017/03/12 Javascript
微信小程序实现倒计时补零功能
2018/07/09 Javascript
JavaScript设计模式之工厂模式和抽象工厂模式定义与用法分析
2018/07/26 Javascript
iview在vue-cli3如何按需加载的方法
2018/10/31 Javascript
详解react组件通讯方式(多种)
2020/05/06 Javascript
使用Vant完成通知栏Notify的提示操作
2020/11/11 Javascript
Python打包文件夹的方法小结(zip,tar,tar.gz等)
2016/09/18 Python
python3将变量输入的简单实例
2020/08/19 Python
如何用python写个模板引擎
2021/01/14 Python
详解window.open被浏览器拦截的解决方案
2019/07/18 HTML / CSS
求职信的七个关键技巧
2014/02/05 职场文书
销售个人求职信范文
2014/04/28 职场文书
募捐倡议书怎么写
2014/05/14 职场文书
关于安全的广播稿
2014/10/23 职场文书
2014年应急工作总结
2014/12/11 职场文书
2015年个人审计工作总结
2015/04/07 职场文书
我的1919观后感
2015/06/03 职场文书
五星红旗迎风飘扬观后感
2015/06/17 职场文书
小学数学继续教育研修日志
2015/11/13 职场文书