您的位置:首页 > 理论基础 > 计算机网络

使用xml http为网站增加域名查询功能

2008-04-24 21:49 615 查看
当我们准备建立一个Web站点时,就必须向域名登记机构申请一个Internet域名,因此,我们通常希望了解自己准备使用的域名是否已经被注册,这时,可以访问NIC站点http://www.nic.net/">http://www.nic.net,点击"whois"链接后输入需查询的域名,就可以得到我们需要的结果。WHOIS服务器为 .com、.net 和 .org 的国际顶级域名的查询返回全部的 whois 数据,包括网站域名注册人、管理合约、联系方式(电话、电子邮件、地址)、帐单联络、技术支持和域名服务器信息,对于用户了解一个网站的基本情况很有帮助。在很多域名注册服务商的网站中,通常都有whois(域名查询)的高级服务,但个人网站因为不具备域名注册服务商的资格和数据,所以在一般条件下无法提供whois服务。
其实,利用http://www.66of.com" target=_blank>xmlhttp协议,我们每个人都可以在自己的个人网站中提供域名详细情况查询(WHOIS)服务,本文介绍了如何使用ASP结合http://www.66of.com" target=_blank>xmlhttp编程来实现这个功能。
一、原理:
原理非常简单,域名的查询主要是基于RFC 954提供的WHOIS协议。在实现过程中,我们通过自己的WEB服务器访问NIC站点的WHOIS数据库服务器,从WHOIS数据库中查询我们所需要的内容,然后通过ASP组合成网页回送给客户端。
同时,我们使用http://www.66of.com" target=_blank>xmlhttp协议实现客户端网页无刷新效果以及向服务端提出检索WHOIS数据的要求。
具体流程为:客户端通过http://www.66of.com" target=_blank>xmlhttp提出域名查询要求-->WEB服务器中的ASP侦听页接受请求后使用http://www.66of.com" target=_blank>xmlhttp向WHOIS服务器发送检索命令-->WHOIS数据库执行查询操作,返回结果给我们自己的WEB服务器(html形式)-->WEB服务器接收到内容后,立即将结果传送给客户端->客户端浏览器使用vbscript过滤掉HTML多余部分,挑选出whois数据显示出来。
二、ASP http://www.66of.com" target=_blank>xmlhttp编程简述:
1、客户端html页面:
<script language="vbscript">
 Sub submit1_onmouseup '当点击“查询”按钮时触发;
  Dim objhttp://www.66of.com" target=_blank>xml, objXSL, objFSO,strFile, strFileName, strXSL,strURL,TheForm
  Set TheForm = Document.wordfind
  window.status="正在检索数据···"
  strURL="dns.asp"
  Set objhttp://www.66of.com" target=_blank>xml = CreateObject("Microsoft.http://www.66of.com" target=_blank>xmlhttp") '创建MS的http://www.66of.com" target=_blank>xmlhttp组件;
  stra = "submit=submit&fqdn="&TheForm.words.value
  objhttp://www.66of.com" target=_blank>xml.Open "post",strURL,false '采用Post提交方式;
  objhttp://www.66of.com" target=_blank>xml.setrequestheader "content-length",len(stra)
  objhttp://www.66of.com" target=_blank>xml.setrequestheader "content-type","application/x-www-form-urlencoded"
  objhttp://www.66of.com" target=_blank>xml.send stra ' 发送信息
  http://www.66of.com" target=_blank>xmlGet = objhttp://www.66of.com" target=_blank>xml.responseText '稍等片刻后,得到服务器端传回来的结果;
  if instr(1,http://www.66of.com" target=_blank>xmlGet,"This is not a valid .com .net .org .info or .biz domain  name",1)<1 and len(trim(http://www.66of.com" target=_blank>xmlGet))>100 then
   if instr(1,http://www.66of.com" target=_blank>xmlGet,"This domain is available",1)<1 then
    if instr(1,http://www.66of.com" target=_blank>xmlGet,"Registrant:",1) then
     strFind1 =instr(1,http://www.66of.com" target=_blank>xmlGet,"Registrant:",1)
    else
     strFind1 = instr(1,http://www.66of.com" target=_blank>xmlGet,"<pre><FONT face=""Verdana, Arial",1) 65
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: