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生成文件
Jan 15 PHP
经典的PHPer为什么被认为是草根?
Apr 02 PHP
php 正则表达式小结
Aug 31 PHP
比较全面的PHP数组的使用方法小结
Sep 23 PHP
利用php递归实现无限分类 格式化数组的详解
Jun 08 PHP
控制PHP的输出:缓存并压缩动态页面
Jun 11 PHP
解析zend studio中直接导入svn中的项目的方法步骤
Jun 21 PHP
php操作memcache缓存方法分享
Jun 03 PHP
微信支付PHP SDK之微信公众号支付代码详解
Dec 09 PHP
PHP的Yii框架中View视图的使用进阶
Mar 29 PHP
Laravel中10个有用的用法小结
May 06 PHP
Yii2框架视图(View)操作及Layout的使用方法分析
May 27 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调用mysql存储过程
2007/02/14 PHP
PHP如何实现Unicode和Utf-8编码相互转换
2015/07/29 PHP
理解PHP中的Session及对Session有效期的控制
2016/01/08 PHP
PHP实现字符串大小写转函数的功能实例
2019/02/06 PHP
EXT窗口Window及对话框MessageBox
2011/01/27 Javascript
JS中window.open全屏命令解析及使用示例
2013/12/11 Javascript
详解JavaScript中的blink()方法的使用
2015/06/08 Javascript
Bootstrap布局方式详解
2016/05/27 Javascript
EXT中单击button按钮grid添加一行(光标位置可设置)的实例代码
2016/06/02 Javascript
JS实现的图片预览插件与用法示例【不上传图片】
2016/11/25 Javascript
Jquery Easyui选项卡组件Tab使用详解(10)
2016/12/18 Javascript
js实现淡入淡出轮播切换功能
2017/01/13 Javascript
JS出现失效的情况总结
2017/01/20 Javascript
vue使用Axios做ajax请求详解
2017/06/07 Javascript
jquery实现放大镜简洁代码(推荐)
2017/06/08 jQuery
JS运动特效之完美运动框架实例分析
2018/01/24 Javascript
Vue 全局loading组件实例详解
2018/05/29 Javascript
koa大型web项目中使用路由装饰器的方法示例
2019/04/02 Javascript
vue中使用带隐藏文本信息的图片、图片水印的方法
2020/04/24 Javascript
element-ui 实现响应式导航栏的示例代码
2020/05/08 Javascript
vue祖孙组件之间的数据传递案例
2020/12/07 Vue.js
[03:21]辉夜杯主赛事 12月25日TOP5
2015/12/26 DOTA
Python中Class类用法实例分析
2015/11/12 Python
python WindowsError的错误代码详解
2017/07/23 Python
Java及python正则表达式详解
2017/12/27 Python
Python numpy实现数组合并实例(vstack,hstack)
2018/01/09 Python
Flask框架学习笔记之表单基础介绍与表单提交方式
2019/08/12 Python
python中rc1什么意思
2020/06/19 Python
Python开发入门——迭代的基本使用
2020/09/03 Python
python中turtle库的简单使用教程
2020/11/11 Python
python Pexpect模块的使用
2020/12/25 Python
html5 canvas绘制矩形和圆形的实例代码
2016/06/16 HTML / CSS
HTML5轻松实现全屏视频背景的示例
2018/04/23 HTML / CSS
交通专业个人自荐信格式
2013/09/23 职场文书
普希金的诗歌赏析(3首)
2019/08/20 职场文书
分析ZooKeeper分布式锁的实现
2021/06/30 Java/Android