域名登记查询(whois)很复杂吗--方法二

voodoo发表于 2000-06-03 22:42:07``` @ Language=VBScript

域名:www. .
 1   
 2dim strResult   
 3if Request.ServerVariables("request_method")="POST" THEN   
 4dim strQuery   
 5'取得需要查询的域名   
 6strQuery=request("domainname") & "." & request("ext")   
 7  
 8dim objSock   
 9'创建sock对象   
10Set objSock=Server.CreateObject("Aspsock.conn")   
11'设置whois服务器为rs.internic.net   
12select case request("ext")   
13case "com","net","org"   
14objSock.RemoteHost="rs.internic.net"   
15gj=0   
16case "com.cn","net.cn","org.cn"   
17objSock.RemoteHost="drop.cnnic.net.cn"   
18gj=1   
19end select   
20'设置whois服务器端口为43   
21objSock.Port=43   
22'设置操作的超时为60秒   
23objSock.TimeOut=60   
24'打开与remotehost的连接,返回真为成功   
25if objSock.Open then   
26'发出查询 WriteLn表示用vbCrlf终结(strQuery & vbCRlf)   
27objSock.WriteLn strQuery   
28'读取返回值,最大长度为65535   
29strResult=objSock.ReadBytesAsString(65535)   
30'关闭连接   
31objSock.Close   
32'打印查询结果,你可以需要对此作些处理   
33' Response.Write "<b>查询结果</b><br/><textarea cols="60" rows="10">" & strResult & "</textarea>"   
34select case gj   
35case "0"   
36str1=inter(strresult)   
37response.write str1   
38Response.Write "<b>查询结果</b><br/><textarea cols="60" rows="10">" & strResult & "</textarea>"   
39case "1"   
40str1=cnnic(strresult)   
41response.write str1   
42Response.Write "<b>查询结果</b><br/><textarea cols="60" rows="10">" & strResult & "</textarea>"   
43end select   
44end if   
45Set objSock=Nothing   
46  
47end if   
48  
49function inter(str)   
50if instr(str,"No match")=0 then   
51response.write "您的域名已经被注册。"   
52else   
53response.write "您的域名没有被注册。"   
54end if   
55end function   
56  
57function cnnic(str)   
58if instr(str,"%")=0 then   
59response.write "您的域名已经被注册。"   
60else   
61response.write "您的域名没有被注册。"   
62end if   
63end function   
```
Published At
Categories with Web编程
Tagged with
comments powered by Disqus