1.新建一个aspx页面,删除前台代码,后台代码如下
try
{
if (Request.QueryString["domains"] != null)
{
StringBuilder sb = new StringBuilder();
sb.Append("[");
foreach (string domain in Request.QueryString["domains"].Split(','))
{
WebRequest wr = WebRequest.Create("http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" + domain);
//wr.Timeout = 10000;
string strHtml = new StreamReader(wr.GetResponse().GetResponseStream()).ReadToEnd();
XmlDocument xd = new XmlDocument();
xd.LoadXml(strHtml);
XmlNode root = xd.SelectSingleNode("property");
sb.Append(",{\"returncode\":\"" + root.ChildNodes[0].InnerText + "\",\"key\":\"" + root.ChildNodes[1].
InnerText + "\",\"original\":\"" + root.ChildNodes[2].InnerText + "\"}");
}
sb.Append("]");
string s = sb.ToString().Replace("[,","[");
Response.Write(s);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
2.通过jquery ajax的方式,调用前面新建的aspx页,如图
$.ajax({
type: "get",
dataType: "json",
url: 'checkdomain.aspx',
data: 'domains='+domains,//此处传递多个域名到checkdomain.aspx,以逗号分隔
cache: false,
success: function (returndata) {
$.each(returndata, function(i, n){
//n.original
//n.key
})
}
});
1、域名查询
接口采用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=qxue8.com
返回XML:
<?xml version="1.0" encoding="gb2312"?>