使用XMLHTTP制作域名查询系统

 1   
 2On Error Resume Next   
 3Server.ScriptTimeOut=9999999   
 4Function getHTTPPage(Path)   
 5t = GetBody(Path)   
 6getHTTPPage=BytesToBstr(t,"GB2312")   
 7End function 
 8
 9Function GetBody(url)   
10on error resume next   
11Set Retrieval = CreateObject("Microsoft.XMLHTTP")   
12With Retrieval   
13.Open "Get", url, False, "", ""   
14.Send   
15GetBody = .ResponseBody   
16End With   
17Set Retrieval = Nothing   
18End Function 
19
20Function BytesToBstr(body,Cset)   
21dim objstream   
22set objstream = Server.CreateObject("adodb.stream")   
23objstream.Type = 1   
24objstream.Mode =3   
25objstream.Open   
26objstream.Write body   
27objstream.Position = 0   
28objstream.Type = 2   
29objstream.Charset = Cset   
30BytesToBstr = objstream.ReadText   
31objstream.Close   
32set objstream = nothing   
33End Function   
 1   
 2if request("domain")<>"" then   
 3'url=" http://panda.www.net.cn/cgi-bin/Whois.cgi?domain="&request("domain")&"&"&request("root")&"=yes&work=whois&referer=http://panda.www.net.cn/cgi-bin/Check.cgi?domain="&request("domain ")   
 4url=" http://panda.www.net.cn/cgi-bin/Check.cgi?domain="&request("domain")&"&ext="&request("root ")   
 5wstr=getHTTPPage(url)   
 6'www.knowsky.com   
 7'response.write Instr (wstr,"可以注册")   
 8if instr(lcase(wstr),"已被注册的域名")>0 then   
 9body="域名已经被注册"   
10elseif instr(lcase(wstr),"未被注册的域名")>0 then   
11body="域名未被注册"   
12else   
13body="网络延迟,请重新查找"   
14end if   
15end if   
 1<table align="center" bgcolor="#999999" border="0" cellpadding="5" cellspacing="1" width="40%">
 2<tr>
 3<td bgcolor="efefef" height="26">域名查询系统:```
 4 if request("domain")&amp;gt;"" then response.Write(request("domain")&amp;amp;"."&amp;amp;request("root")&amp;amp;body) end if
 5```</td>
 6</tr>
 7<tr>
 8<td bgcolor="#FFFFFF"><form action="" method="post" name="form1"><table border="0" cellpadding="1" cellspacing="1" width="100%">
 9<tr>
10<td height="36"> <div align="center">www.   
11<input name="domain" type="text"/>
12<select id="select" name="root">
13<option selected="" value="cn">.cn</option>
14<option value="com">.com</option>
15<option value="net">.net</option>
16<option value="org">.org</option>
17<option value="com.cn">.com.cn</option>
18<option value="net.cn">.net.cn</option>
19<option value="gov.cn">.gov.cn</option>
20</select>
21</div></td>
22</tr>
23<tr>
24<td height="35">
25<div align="center">
26<input name="Submit" type="submit" value=" 查 询 "/>
27</div>
28<div align="center"></div></td>
29</tr>
30</table></form></td>
31</tr>
32</table>
1<p align="center"> </p>
 1<table align="center" bgcolor="#999999" border="0" cellpadding="5" cellspacing="1" width="40%">
 2<tr>
 3<td bgcolor="#FFFFFF" height="42">
 4<form action="http://search.sohu.com/web" method="get" name="search_form" target="_blank">
 5<div align="center">
 6<input name="pid" type="hidden" value="hljec"/>
 7<input name="query" style="font-size:14px;width:150" type="text" value="好域名"/>
 8<input name="ss" onclick="document.search_form.action='http://search.sohu.com/web'" style="font-size:14px;width=40;height=20" type="submit" value="查看"/>   
 9 </div>
10</form></td>
11</tr>
12</table>

代码我已经在本地测试过了。正常通过。
文章里面的用到的Microsoft.XMLHTTP组件。其用法请参见: http://www.knowsky.com/5190.html

Published At
Categories with Web编程
Tagged with
comments powered by Disqus