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 相关文章推荐
桌面中心(一)创建数据库
Oct 09 PHP
使用php重新实现PHP脚本引擎内置函数
Mar 06 PHP
php正则校验用户名介绍
Jul 19 PHP
php 获取SWF动画截图示例代码
Feb 10 PHP
php数组排序usort、uksort与sort函数用法
Nov 17 PHP
php+mysql数据库实现无限分类的方法
Dec 12 PHP
详解Laravel视图间共享数据与视图Composer
Aug 04 PHP
PHP利用超级全局变量$_GET来接收表单数据的实例
Nov 05 PHP
PHP中register_shutdown_function函数的基础介绍与用法详解
Nov 28 PHP
PHP设计模式之工厂模式定义与用法详解
Apr 03 PHP
PHP实现上传图片到数据库并显示输出的方法
May 31 PHP
thinkPHP5框架接口写法简单示例
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和ACCESS写聊天室(九)
2006/10/09 PHP
php连接函数implode与分割explode的深入解析
2013/06/26 PHP
PHP根据传来的16进制颜色代码自动改变背景颜色
2014/06/13 PHP
php中Array2xml类实现数组转化成XML实例
2014/12/08 PHP
PHP MVC框架路由学习笔记
2016/03/02 PHP
PHP常用字符串函数用法实例总结
2020/06/04 PHP
JS获取单击按钮单元格所在行的信息
2014/06/17 Javascript
jQuery 写的简单打字游戏可以提示正确和错误的次数
2014/07/01 Javascript
nodejs中转换URL字符串与查询字符串详解
2014/11/26 NodeJs
JavaScript操作Cookie详解
2015/02/28 Javascript
js数组依据下标删除元素
2015/04/14 Javascript
jquery实现实时改变网页字体大小、字体背景色和颜色的方法
2015/08/05 Javascript
jQuery插件开发精品教程让你的jQuery提升一个台阶
2016/01/27 Javascript
JavaScript 轮播图和自定义滚动条配合鼠标滚轮分享代码贴
2016/10/28 Javascript
JavaScript中定义对象原型的两种使用方法
2016/12/15 Javascript
js/jquery控制页面动态加载数据 滑动滚动条自动加载事件的方法
2017/02/08 Javascript
js实现登录框鼠标拖拽效果
2017/03/09 Javascript
JavaScript实现的选择排序算法实例分析
2017/04/14 Javascript
vue源码入口文件分析(推荐)
2018/01/30 Javascript
React Native基础入门之初步使用Flexbox布局
2018/07/02 Javascript
axios全局注册,设置token,以及全局设置url请求网段的方法
2018/09/25 Javascript
js实现星星打分效果
2020/07/05 Javascript
es5 类与es6中class的区别小结
2020/11/09 Javascript
Python3实现腾讯云OCR识别
2018/11/27 Python
使用Python快乐学数学Github万星神器Manim简介
2019/08/07 Python
matplotlib基础绘图命令之imshow的使用
2020/08/13 Python
python中PyQuery库用法分享
2021/01/15 Python
英国时尚配饰、珠宝和服装网站:KJ Beckett
2020/01/23 全球购物
JBL加拿大官方商店:扬声器、耳机等
2020/10/23 全球购物
验房委托书
2014/08/30 职场文书
初中毕业典礼演讲稿
2014/09/09 职场文书
辞职信范文大全
2015/03/02 职场文书
农民工工资承诺书大全
2015/05/04 职场文书
初二英语教学反思
2016/02/15 职场文书
写作技巧:如何撰写商业计划书
2019/08/08 职场文书
MySQL 1130异常,无法远程登录解决方案详解
2021/08/23 MySQL