<% on error resume next server.scripttimeout=9999999 function gethttppage(path) t = getbody(path) gethttppage=bytestobstr(t,"gb2312") 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 request("domain")<>"" then 'url=" referer=http://panda.www.net.cn/cgi-bin/check.cgi?domain="&request("domain") url="http://panda.www.net.cn/cgi-bin/check.cgi?domain="&request("domain")&"&ext="&request("root") wstr=gethttppage(url) 'www.knowsky.com 'response.write instr (wstr,"可以注册") if instr(lcase(wstr),"已被注册的域名")>0 then body="域名已经被注册" elseif instr(lcase(wstr),"未被注册的域名")>0 then body="域名未被注册" else body="网络延迟,请重新查找" end if end if %> <table width="40%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999"> <tr> <td height="26" bgcolor="efefef">域名查询系统:<% if request("domain")>"" then response.write(request("domain")&"."&request("root")&body) end if%></td> </tr> <tr> <td bgcolor="#ffffff"><form name="form1" method="post" action=""><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td height="36"> <div align="center">www. <input type="text" name="domain"> <select name="root" id="select"> <option value="cn" selected>.cn</option> <option value="com">.com</option> <option value="net">.net</option> <option value="org">.org</option> <option value="com.cn">.com.cn</option> <option value="net.cn">.net.cn</option> <option value="gov.cn">.gov.cn</option> </select> </div></td> </tr> <tr> <td height="35"> <div align="center"> <input type="submit" name="submit" value=" 查 询 "> </div> <div align="center"></div></td> </tr> </table></form></td> </tr> </table> <p align="center"> </p> <table width="40%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999"> <tr> <td height="42" bgcolor="#ffffff"> <form name=search_form action='http://search.sohu.com/web' method=get target=_blank> <div align="center"> <input type="hidden" name="pid" value="hljec"> <input name="query" type="text" style="font-size:14px;width:150" value="好域名"> <input type="submit" name="ss" value="查看"onclick=document.search_form.action='http://search.sohu.com/web' style="font-size:14px;width=40;height=20"> </div> </form></td> </tr> </table>
代码我已经在本地测试过了。正常通过。
以上就是如何使用xmlhttp制作域名查询系统的代码案例的详细内容。
