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 09 PHP
php中获得视频时间总长度的另一种方法
Sep 15 PHP
php生成略缩图代码
Jul 16 PHP
使用迭代器 遍历文件信息的详解
Jun 08 PHP
php使用array_rand()函数从数组中随机选择一个或多个元素
Apr 28 PHP
PHP生成数组再传给js的方法
Aug 07 PHP
mac环境中使用brew安装php5.5.15
Aug 18 PHP
php验证码实现代码(3种)
Sep 07 PHP
php开发微信支付获取用户地址
Oct 04 PHP
php实现批量删除挂马文件及批量替换页面内容完整实例
Jul 08 PHP
PHP树形结构tree类用法示例
Feb 01 PHP
Swoole源码中如何查询Websocket的连接问题详解
Aug 30 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
咖啡冲泡指南 咖啡有哪些制作方式 单品咖啡 意式咖啡
2021/03/06 冲泡冲煮
PHP生成网页快照 不用COM不用扩展.
2010/02/11 PHP
ThinkPHP验证码和分页实例教程
2014/08/22 PHP
SyntaxHighlighter代码加色使用方法
2008/09/07 Javascript
Javascript解决常见浏览器兼容问题的12种方法
2010/01/04 Javascript
javascript 延迟加载技术(lazyload)简单实现
2011/01/17 Javascript
Javascript公共脚本库系列(一): 弹出层脚本
2011/02/24 Javascript
Jquery倒数计时按钮setTimeout的实例代码
2013/07/04 Javascript
jquery插件jTimer(jquery定时器)使用方法
2013/12/23 Javascript
jQuery验证插件validate使用方法详解
2020/09/13 Javascript
webpack常用配置项配置文件介绍
2016/11/07 Javascript
vue-drag-chart 拖动/缩放图表组件的实例代码
2020/04/10 Javascript
vue使用swiper实现左右滑动切换图片
2020/10/16 Javascript
Node.js path模块,获取文件后缀名操作
2020/11/07 Javascript
python正则表达式修复网站文章字体不统一的解决方法
2013/02/21 Python
python实现目录树生成示例
2014/03/28 Python
wxPython框架类和面板类的使用实例
2014/09/28 Python
研究Python的ORM框架中的SQLAlchemy库的映射关系
2015/04/25 Python
使用Python生成XML的方法实例
2017/03/21 Python
python django 实现验证码的功能实例代码
2017/05/18 Python
人工神经网络算法知识点总结
2019/06/11 Python
详解Pandas之容易让人混淆的行选择和列选择
2019/07/10 Python
Python的Tkinter点击按钮触发事件的例子
2019/07/19 Python
Python 调用 Windows API COM 新法
2019/08/22 Python
一行Python代码制作动态二维码的实现
2019/09/09 Python
python文字转语音的实例代码分析
2019/11/12 Python
解决Python import docx出错DLL load failed的问题
2020/02/13 Python
Python rabbitMQ如何实现生产消费者模式
2020/08/24 Python
详解python os.path.exists判断文件或文件夹是否存在
2020/11/16 Python
美国最大的骑马用品零售商:HorseLoverZ
2017/01/12 全球购物
美国林业供应商:Forestry Suppliers
2019/05/01 全球购物
对象的序列化(serialization)类是面向流的,应如何将对象写入到随机存取文件中
2015/06/22 面试题
挂职自我鉴定
2014/02/26 职场文书
《傅雷家书》教学反思
2014/04/20 职场文书
2014统计局民主生活会对照检查材料思想汇报
2014/10/02 职场文书
分享几个简单MySQL优化小妙招
2022/03/31 MySQL