21
2008
09

域名whois查询接口代码

1、域名check

接口采用HTTP,POST,GET协议:
调用URL:http://panda.www.net.cn/cgi-bin/check.cgi
参数名称:area_domain 值为标准域名,例:hichina.com
调用举例:http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=hichina.com
返回XML:

200
2zher3r3r.com
210 : Domain name is available

返回XML结果说明:
returncode=200 表示接口返回成功
key=***.com表示当前check的域名
original=210 : Domain name is available     表示域名可以注册
original=211 : Domain name is not available  表示域名已经注册
original=212 : Domain name is invalid   表示域名参数传输错误

2、域名info

接口采用HTTP,POST,GET协议:
调用URL:http://whois.hichina.com/cgi-bin/whois
参数名称:domain  值为标准域名,例:hichina.com
调用举例:http://whois.hichina.com/cgi-bin/whois?domain=hichina.com
返回文本:其中在字符

与字符

之间即为域名信息内容。

3. 示例

提供一个asp的示例,以供参考

<%

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


Function GetKey(HTML,Start,Last) 

body1=split(HTML,Start) 

body2=split(body1(1),Last) 

GetKey=body2(0) 

End Function

%>

<form id="form1" name="form1" method="post" action="whois.asp?post=1">

请出入您要查询的域名:www.<input type="text" name="dname" />

<input type="submit" name="Submit" value="查询" />

</form>

<%

if request.QueryString("post") = "1" then

dname = trim(request.Form("dname"))

regurl = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" & dname

reghtml = getHTTPPage(regurl)

if GetKey(reghtml,"<returncode>","</returncode>") <> "200" and GetKey(reghtml,"<original>","</original>") <> "211 : Domain name is invalid" and GetKey(reghtml,"<original>","</original>") <> "210 : Domain name is available" then

response.Write "您输入的域名格式错误!<br />"

response.Write "<a href=""http://www.u6u8.net/whois.asp"">返回</a>"

else

if GetKey(reghtml,"<original>","</original>") = "211 : Domain name is not available" then

response.Write dname & "已经被注册!<br /><br /> Whois信息:<br />"

whoisurl = "http://whois.hichina.com/cgi-bin/whois?domain=" & dname

response.Write "<pre>" & GetKey(getHTTPPage(whoisurl),"<pre>","请您注意特别提示:") & "</pre>"

else

response.Write dname & "可以注册!"

end if

end if

end if

%>

演示 : http://www.u6u8.net/whois.asp

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。