php whois查询API制作方法_php技巧

这里我们从万网或新网的数据接口取得数据,透过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

时间: 2024-08-01 20:39:59

php whois查询API制作方法_php技巧的相关文章

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/domai

PHP访问Google Search API的方法_php技巧

本文实例讲述了PHP访问Google Search API的方法.分享给大家供大家参考.具体如下: 这段代码段演示了如何从php向AJAX搜索API发送请求.请注意,此示例假定使用 PHP 5.2.对于较早安装的 PHP,请参考对应的官方注释. 具体代码如下: 复制代码 代码如下: $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Paris%20Hilton";   // sendReque

php调用新浪短链接API的方法_php技巧

本文实例讲述了php调用新浪短链接API的方法.分享给大家供大家参考.具体方法如下: 复制代码 代码如下: <?php //Sina App_Key define('SINA_APPKEY', '31641035'); function curlQuery($url) {  //设置附加HTTP头  $addHead = array(  "Content-type: application/json"  );  //初始化curl,当然,你也可以用fsockopen代替  $cu

php连接oracle数据库及查询数据的方法_php技巧

本文实例讲述了php连接oracle数据库及查询数据的方法.分享给大家供大家参考.具体分析如下: php有强大的功能不但可以支持mysql,mssql,mysqli之个我们还可以与oracle数据连接,要让php支持oracle非常的简单我们只要把php.ini中的;extention = php_oci8.dll分号去掉即可. php支持oracle连接函数 php.ini文件中的配置,去掉 ;extention = php_oci8.dll,去掉前面的分号,重启apache就可以了,如果不行

php连接odbc数据源并保存与查询数据的方法_php技巧

本文实例讲述了php连接odbc数据源并保存与查询数据的方法.分享给大家供大家参考. 具体实现代码如下: 复制代码 代码如下: $connstr = "driver=microsoft access driver (*.mdb);dbq=".realpath("db.mdb");     $connid = odbc_connect($connstr,"","",sql_cur_use_odbc); $odbc_exec =

php动态添加url查询参数的方法_php技巧

本文实例讲述了php动态添加url查询参数的方法.分享给大家供大家参考.具体分析如下: 这段代码可以动态为url添加key-value查询参数,如果参数已经存在则会用新的进行覆盖 function add_querystring_var($url, $key, $value) { $url=preg_replace('/(.*)(?|&)'.$key.'=[^&]+?(&)(.*)/i','$1$2$4',$url.'&'); $url=substr($url,0,-1);

详解WordPress中给链接添加查询字符串的方法_php技巧

查询字符串指的是链接中后边的问号后的查询语句,格式为 key=value,多个查询语句用 & 符号分开.add_query_arg() 函数就是 WordPress 提供的一个方便的函数,可以帮你给一个链接添加一个或者多个查询语句. 有人会问,添加查询字符串直接在链接后边手动追加不就可以了吗?这样有时候可行,但链接如果本身就有查询字符串就会造成格式错误的问题,而且也不利于 PHP 编写管理,而 add_query_arg() 函数帮你把一切都想好了,你只需要给出要添加查询字符串的链接和一个或多个

用PHP实现多服务器共享SESSION数据的方法_php技巧

PHP 实现多服务器共享 SESSION 数据 /google 的广告条--> 一.问题起源 稍大一些的网站,通常都会有好几个服务器,每个服务器运行着不同功能的模块,使用不同的二级域名,而一个整体性强的网站,用户系统是统一的,即一套用户名.密码在整个网站的各个模块中都是可以登录使用的.各个服务器共享用户数据是比较容易实现的,只需要在后端放个数据库服务器,各个服务器通过统一接口对用户数据进行访问即可.但还存在一个问题,就是用户在这个服务器登录之后,进入另一个服务器的别的模块时,仍然需要重新登录,这

PHP读取PPT文件的方法_php技巧

本文实例讲述了PHP读取PPT文件的方法.分享给大家供大家参考,具体如下: 最近做一个和FLASH有关的东西,其中就要用到在网站上看PPT就像百度,豆丁网那样可以直接在网站上读,在网上搜了半天没搜到,都是些什么安装个软件什么的,PHP网站放到空间上,谁能让你在哪装软件呢?不是在瞎扯么?不过还好,最后在国外一个网站上搜到了一个解决思路,就是一个PHP操作PPT的类,当然这个网站还提供了操作OFFICES软件的其他类,不过是2007版的OFFICES,现把网址贴出来奉献给大家:http://phpp