php whois查询API制作方法

 更新时间:2011年06月23日 22:13:51   作者:  
网站们经常需要查询网站whois信息,这里介绍一个使用php制作的whois api接口,方法也很简单,下面详细介绍一下。
这里我们从万网或新网的数据接口取得数据,透过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中each与list用法分析

    PHP中each与list用法分析

    这篇文章主要介绍了PHP中each与list用法,结合实例形式分析了each及list函数的使用技巧,并举例分析了each结合list函数实现数组遍历的技巧,需要的朋友可以参考下
    2016-01-01
  • 发款php蜘蛛统计插件只要有mysql就可用

    发款php蜘蛛统计插件只要有mysql就可用

    有时候我们为了看一下蜘蛛爬行的情况,不得不对日志进行大量的分析,由此想做一款插件可以记录蜘蛛的情况。在第一次做的时候,只是记录下蜘蛛的爬行次数,不大好分析。
    2010-10-10
  • 适用于初学者的简易PHP文件上传类

    适用于初学者的简易PHP文件上传类

    这篇文章主要为大家分享了一个适用于初学者的简易PHP文件上传类,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2015-10-10
  • php版微信返回用户text输入的方法

    php版微信返回用户text输入的方法

    这篇文章主要介绍了php版微信返回用户text输入的方法,结合实例形式分析了php实现的微信解析及返回用户输入数据的相关操作技巧,需要的朋友可以参考下
    2016-11-11
  • php-fpm超时时间设置request_terminate_timeout资源问题分析

    php-fpm超时时间设置request_terminate_timeout资源问题分析

    之前发现一个php配置之后关于返回500和502的问题,今天看到一个兄弟写的非常不错,记录一下
    2019-09-09
  • PHP 返回13位时间戳的实现代码

    PHP 返回13位时间戳的实现代码

    下面小编就为大家带来一篇PHP 返回13位时间戳的实现代码。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2016-05-05
  • XAMPP升级PHP版本实现步骤解析

    XAMPP升级PHP版本实现步骤解析

    这篇文章主要介绍了XAMPP升级PHP版本实现步骤解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-09-09
  • php中opendir函数用法实例

    php中opendir函数用法实例

    这篇文章主要介绍了php中opendir函数用法,以实例形式详细讲述了opendir函数打开目录的用法及相关的注意事项,具有一定的参考借鉴价值,需要的朋友可以参考下
    2014-11-11
  • php使用memcoder将视频转成mp4格式的方法

    php使用memcoder将视频转成mp4格式的方法

    这篇文章主要介绍了php使用memcoder将视频转成mp4格式的方法,涉及php操作视频文件的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-03-03
  • PHP 图片上传代码

    PHP 图片上传代码

    昨天晚上自学的一段代码到公司来调试。很顺利,到了中午的时候基本上添加、修改、删除,这些在代码世界中最基础的功能都基本实现了,蛮有成就感的。
    2011-09-09

最新评论