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 相关文章推荐
Windows下PHP5和Apache的安装与配置
Sep 05 PHP
PHP与javascript对多项选择的处理
Oct 09 PHP
深入解析php模板技术原理【一】
Jan 10 PHP
PHP 加密解密内部算法
Apr 22 PHP
关于crontab的使用详解
Jun 24 PHP
php截取字符串函数substr,iconv_substr,mb_substr示例以及优劣分析
Jun 10 PHP
PHP动态编译出现Cannot find autoconf的解决方法
Nov 05 PHP
PHP抓取网页、解析HTML常用的方法总结
Jul 01 PHP
php简单判断文本编码的方法
Jul 30 PHP
PHP执行linux命令常用函数汇总
Feb 02 PHP
深入浅析yii2-gii自定义模板的方法
Apr 26 PHP
PHP里的$_GET数组介绍
Mar 22 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游戏编程25个脚本代码
2011/02/08 PHP
利用PHP抓取百度阅读的方法示例
2016/12/18 PHP
YUI的Tab切换实现代码
2010/04/11 Javascript
如何将JS的变量值传递给ASP变量
2012/12/10 Javascript
Jquery下EasyUI组件中的DataGrid结果集清空方法
2014/01/06 Javascript
jquery css 设置table的奇偶行背景色示例
2014/06/03 Javascript
js操作IE浏览器弹出浏览文件夹可以返回目录路径
2014/07/14 Javascript
js生成的验证码的实现与技术分析
2014/09/17 Javascript
JavaScript字符串对象的concat方法实例(用于连接两个或多个字符串)
2014/10/16 Javascript
JS+CSS实现感应鼠标渐变显示DIV层的方法
2015/02/20 Javascript
JavaScript实现Base64编码转换
2016/04/23 Javascript
javascript字符串对象常用api函数小结(连接,替换,分割,转换等)
2016/09/20 Javascript
AngularJS中指令的四种基本形式实例分析
2016/11/22 Javascript
Bootstrap CSS布局之列表
2016/12/15 Javascript
Vue通过input筛选数据
2020/10/26 Javascript
js禁止Backspace键使浏览器后退的实现方法
2017/09/01 Javascript
详解ES6语法之可迭代协议和迭代器协议
2018/01/13 Javascript
Promise.all中对于reject的处理方法
2018/08/01 Javascript
原生js实现trigger方法示例代码
2019/05/22 Javascript
JS实现点餐自动选择框(案例分析)
2019/12/10 Javascript
react结合bootstrap实现评论功能
2020/05/30 Javascript
[51:36]EG vs VP 2018国际邀请赛淘汰赛BO3 第一场 8.24
2018/08/25 DOTA
Python中使用Inotify监控文件实例
2015/02/14 Python
python使用cStringIO实现临时内存文件访问的方法
2015/03/26 Python
详解Python中映射类型(字典)操作符的概念和使用
2015/08/19 Python
Python实现控制台中的进度条功能代码
2017/12/22 Python
Python爬取商家联系电话以及各种数据的方法
2018/11/10 Python
Python3解释器知识点总结
2019/02/19 Python
python顺序执行多个py文件的方法
2019/06/29 Python
基于python3 pyQt5 QtDesignner实现窗口化猜数字游戏功能
2019/07/15 Python
Python3利用openpyxl读写Excel文件的方法实例
2021/02/03 Python
英国受欢迎的运动鞋和街头服装商店:Footasylum
2018/06/12 全球购物
全球最大的瓷器、水晶和银器零售商:Replacements
2020/06/15 全球购物
总裁办公室主任职责
2014/01/02 职场文书
保密工作承诺书
2014/08/29 职场文书
MySQL串行化隔离级别(间隙锁实现)
2022/06/16 MySQL