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 反射机制实现动态代理的代码
Oct 22 PHP
PHP与SQL注入攻击防范小技巧
Sep 16 PHP
将时间以距今多久的形式表示,PHP,js双版本
Sep 25 PHP
浅谈PHP强制类型转换,慎用!
Jun 06 PHP
PHP网页游戏学习之Xnova(ogame)源码解读(十四)
Jun 26 PHP
php获取指定范围内最接近数的方法
Jun 02 PHP
php使用ftp远程上传文件类(完美解决主从文件同步问题的方法)
Sep 23 PHP
PHP输出图像imagegif、imagejpeg与imagepng函数用法分析
Nov 14 PHP
php 解决扫描二维码下载跳转问题
Jan 13 PHP
php中的异常和错误浅析
May 03 PHP
PHP7如何开启Opcode打造强悍性能详解
May 11 PHP
PHP htmlentities()函数用法讲解
Feb 25 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 array_flip() 删除数组重复元素
2009/01/14 PHP
phpword插件导出word文件时中文乱码问题处理方案
2014/08/19 PHP
如何使用jQuery+PHP+MySQL来实现一个在线测试项目
2015/04/26 PHP
php实现json编码的方法
2015/07/30 PHP
mac pecl 安装php7.1扩展教程
2019/10/17 PHP
JavaScript 特殊字符
2007/04/05 Javascript
地震发生中逃生十大法则
2008/05/12 Javascript
jquery checkbox,radio是否选中的判断代码
2010/03/20 Javascript
Javascript 去除数组的重复元素
2010/05/04 Javascript
JS+CSS实现一个气泡提示框
2013/08/18 Javascript
jquery分页对象使用示例
2014/04/01 Javascript
谷歌地图打不开的解决办法
2014/08/07 Javascript
JQuery中上下文选择器实现方法
2015/05/18 Javascript
18个非常棒的jQuery代码片段
2015/11/02 Javascript
详解nodejs 开发企业微信第三方应用入门教程
2019/03/12 NodeJs
ajaxfileupload.js实现上传文件功能
2019/04/19 Javascript
JS数组扁平化(flat)方法总结详解
2019/06/24 Javascript
基于vue手写tree插件的那点事儿
2019/08/20 Javascript
js遍历详解(forEach, map, for, for...in, for...of)
2019/08/28 Javascript
vue中echarts图表大小适应窗口大小且不需要刷新案例
2020/07/19 Javascript
[01:35]辉夜杯战队访谈宣传片—iG.V
2015/12/25 DOTA
[01:09:40]Newbee vs Pain 2018国际邀请赛小组赛BO2 第一场 8.16
2018/08/17 DOTA
python 在屏幕上逐字显示一行字的实例
2018/12/24 Python
python实现批量注册网站用户的示例
2019/02/22 Python
解决Pytorch训练过程中loss不下降的问题
2020/01/02 Python
python实现简单俄罗斯方块
2020/03/13 Python
python字符串的index和find的区别详解
2020/06/20 Python
jupyter notebook快速入门及使用详解
2020/11/13 Python
canvas烟花特效锦集
2018/01/17 HTML / CSS
加大码胸罩、内裤和服装:Just My Size
2019/03/21 全球购物
什么是聚集索引和非聚集索引
2012/01/17 面试题
保研推荐信
2014/05/09 职场文书
法人身份证明书
2014/10/08 职场文书
公司员工手册范本
2015/05/14 职场文书
无罪辩护词范文
2015/05/21 职场文书
学子宴致辞大全
2015/07/27 职场文书