域名批量查询功能实现思路

<%
On Error Resume Next
Server.ScriptTimeOut=9999999

action=Request.QueryString("action")

Function getHTTPPage(Path)
         t = GetBody(Path)
         getHTTPPage=BytesToBstr(t,"GB2312")
End function
Function CleanHtml(str)
Dim RegEx      
Set RegEx = New RegExp      
RegEx.Pattern = "<\/*[^<>]*>|{\/*[^{}]*>"
RegEx.Global = True      
CleanHtml = RegEx.Replace(str, "")   
End Function
Function GetBody(url)
on error resume next
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
   .Open "Get", url, False, "", ""
   .Send
   GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb."&"stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

If action="do" then
domain = trim(Request.Form("domain"))
root = trim(Request.Form("root"))
If Len(domain)=0 Or Len(root)=0 Then
   Response.Write "两者不能为空"
   Response.End()
End If

domain = Replace(domain,"'","")
root = Replace(root,"'","")
arrRoot=Split(root,",")
body=""

For i=0 To ubound(arrRoot)'进行多个域名后缀查询时通过循环进行列表查询
   url="http://panda.www.net.cn/cgi-bin/Check.cgi?domain="&trim(domain)&"&ext="&trim(arrRoot(i))
   sDomain=trim(domain)&"."&trim(arrRoot(i))
  
   wstr=CleanHtml(getHTTPPage(url))

   If instr(lcase(wstr),"已经被注册")>0 then
    body=body&"<a href=whois.asp?domain="&sDomain&" target='new' title='点击查看该域名的WHOIS'>域名 "&sDomain&" 已经被注册,点击查看WHOIS</a><br>"
   Elseif instr(lcase(wstr),"没有被注册")>0 then
    body=body&"<a href='Domainregister.asp?domain="+sDomain+"' target='new' title='点击注册该域名'>域名 "&sDomain&" 未被注册,点击注册该域名</a><br>"
   Else
    body=body&"域名 "&sDomain&" 查询超时,请重新查找<br>"
   End If
   'Response.Write "<textarea rows='4' style='width:80%'>"&wstr&"</textarea><br>"&sDomain&"<br>"&body&"<br>"
Next
%>

<table border="0" width="550" cellspacing="0" cellpadding="0" align=center>
   <tr bgcolor="#EFEFEF">
    <td height="30"><strong>域名查询结果:</strong></td>
   </tr>
   <tr>
    <td style="padding-left:20px;line-height:200%;">
      <%
      if body="" then
       response.write "域名查询有错误!"
      Else
       response.write body
      end If
      %>
    </td>
   </tr>
</table><br>
<%End If%>

<table border="0" width="550" cellspacing="0" cellpadding="0" align=center>
<FORM action="?action=do" method="post">
<tr bgcolor="#EFEFEF">
   <td height="30">
    <img border="0" src="www.gif" width="102" height="20">
    <INPUT size=25 name="domain">
   </td>
   <td height="34" width="30%" style="padding-left:10px;"><INPUT type=submit value="查 询"></td>
</tr>
<tr>
   <td colspan=2 align=center>
    <TABLE class=eng cellSpacing=0 cellPadding=0 width="95%" border=0>
     <TR>
      <TD><INPUT type="checkbox" value="com" name="root" Checked>.com</TD>
      <TD><INPUT type="checkbox" value="net" name="root" Checked>.net</TD>
      <TD><INPUT type="checkbox" value="org" name="root">.org</TD>
      <TD><INPUT type="checkbox" value="cn" name="root" Checked>.cn</TD>
      <TD><INPUT type="checkbox" value="info" name="root">.info</TD></TR>
     <TR>
      <TD><INPUT type="checkbox" value="com.cn" name="root">.com.cn</TD>
      <TD><INPUT type="checkbox" value="net.cn" name="root">.net.cn</TD>
      <TD><INPUT type="checkbox" value="org.cn" name="root">.org.cn</TD>
      <TD><INPUT type="checkbox" value="biz" name="root">.biz</TD>
      <TD><INPUT type="checkbox" value="name" name="root">.name</TD>
     </TR>
     <TR>
      <TD><INPUT type="checkbox" value="cc" name="root">.cc</TD>
      <TD><INPUT type="checkbox" value="tv" name="root">.tv</TD>
      <TD><INPUT type="checkbox" value="mobi" name="root">.mobi</TD>
      <TD><INPUT type="checkbox" value="网络" name="root">.网络</TD>
      <TD><INPUT type="checkbox" value="公司" name="root">.公司</TD>
     </TR>
    </TABLE>
   </td>
</tr>
</form>
</table>

<div id=divProcessing style="width:200px;height:30px;position:absolute;left:70px;top:180px;display:none;FILTER: Alpha(opacity=65);">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#3A6EA5" width="100%" height="100%"><tr><td bgcolor=#feffef>
<img style="MARGIN: 3px" alt="数据载入中..." src="Ploading.gif"><br>
<marquee align="middle" behavior="alternate" scrollamount="5"><font color=#FF0000>...正在查询...请等待...</font></marquee></td></tr></table>
</div>

posted @ 2007-04-09 20:25  已經停更  阅读(261)  评论(0编辑  收藏  举报