2012-03-18
關鍵詞:
4859
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"?>