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 相关文章推荐
分页显示Oracle数据库记录的类之一
Oct 09 PHP
无数据库的详细域名查询程序PHP版(1)
Oct 09 PHP
PHP 的 __FILE__ 常量
Jan 15 PHP
php线性表顺序存储实现代码(增删查改)
Feb 16 PHP
php 模拟POST提交的2种方法详解
Jun 17 PHP
PHP连接MySQL的2种方法小结以及防止乱码
Mar 11 PHP
php计算税后工资的方法
Jul 28 PHP
PHP Web木马扫描器代码分享
Sep 06 PHP
php5.5使用PHPMailer-5.2发送邮件的完整步骤
Oct 14 PHP
php和asp语法上的区别总结
May 12 PHP
PHP+MySql实现一个简单的留言板
Jul 19 PHP
Thinkphp5+Redis实现商品秒杀代码实例讲解
Dec 29 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中进行身份认证
2006/10/09 PHP
php strstr查找字符串中是否包含某些字符的查找函数
2010/06/03 PHP
如何在centos8自定义目录安装php7.3
2019/11/28 PHP
用javascript实现给图片加链接
2007/08/15 Javascript
JavaScript 面向对象编程(1) 基础
2010/05/18 Javascript
一个收集图片的bookmarlet(js 刷新页面中的图片)
2010/05/27 Javascript
JavaScript中两个感叹号的作用说明
2011/12/28 Javascript
jQuery学习笔记 获取jQuery对象
2012/09/19 Javascript
jquery获取table中的某行全部td的内容方法
2013/03/08 Javascript
jquery ajax jsonp跨域调用实例代码
2013/12/11 Javascript
jQuery+PHP星级评分实现方法
2015/10/02 Javascript
JS获取IMG图片高宽的简单实例
2016/05/17 Javascript
jquery制做精致的倒计时特效
2016/06/13 Javascript
JS作用域深度解析
2016/12/29 Javascript
解决vue router组件状态刷新消失的问题
2018/08/01 Javascript
vue路由传参三种基本方式详解
2019/12/09 Javascript
python脚本实现查找webshell的方法
2014/07/31 Python
简单谈谈Python中的几种常见的数据类型
2017/02/10 Python
Python爬虫中urllib库的进阶学习
2018/01/05 Python
Python设计模式之桥接模式原理与用法实例分析
2019/01/10 Python
解决Python3 被PHP程序调用执行返回乱码的问题
2019/02/16 Python
python解析命令行参数的三种方法详解
2019/11/29 Python
python中设置超时跳过,超时退出的方式
2019/12/13 Python
Python selenium自动化测试模型图解
2020/04/15 Python
Python脚本破解压缩文件口令实例教程(zipfile)
2020/06/14 Python
python调用百度API实现人脸识别
2020/11/17 Python
Python基于unittest实现测试用例执行
2020/11/25 Python
移动端适配 使px自动转换rem
2019/08/26 HTML / CSS
阿里旅行:飞猪
2017/01/05 全球购物
松本清官方海外旗舰店:日本最大的药妆连锁店
2017/11/21 全球购物
塑料制成的可水洗的编织平底鞋和鞋子:Rothy’s
2018/09/16 全球购物
优秀辅导员事迹材料
2014/02/16 职场文书
三月法制宣传月活动总结
2014/07/03 职场文书
幼儿园保育员责任书
2014/07/22 职场文书
详解Java线程池是如何重复利用空闲线程的
2021/06/26 Java/Android
深入理解pytorch库的dockerfile
2022/06/10 Python