http://panda.www.net.cn/cgi-bin/check.cgi
接口参数(GET)
area_domain:查询域名
返回内容
<?xml version="1.0" encoding="gb2312"?>
<property>
<returncode>接口状态码,200为成功</returncode>
<key>查询域名</key>
<original>域名状态</original>
</property>
original值类型:
1).域名可以注册:210 : Domain name is available
2).域名已经注册:211 : Domain name is not available
3).参数传输错误:212 : Domain name is invalid
4).查询超时:213 : Timeout
C#域名查询类
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
namespace ConsoleApplication1
{
public static class Domain
{
/// <summary>
/// 域名查询
/// </summary>
/// <param name="domain"></param>
/// <returns>
/// -1 : Exception
/// 210 : Domain name is available
/// 211 : Domain name is not available
/// 212 : Domain name is invalid
/// 213 : Timeout
/// </returns>
public static int Check(string domain)
{
int result = -1;
try
{
Encoding encoding = Encoding.GetEncoding("gb2312");
Uri uri = new Uri(string.Format("http://panda.www.net.cn/cgi-bin/check.cgi?area_domain={0}", domain));
WebRequest webRequest = WebRequest.Create(uri);
WebResponse webResponse = webRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), encoding))
{
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(streamReader.ReadToEnd());
XmlNode xmlNode = xmlDocument.SelectSingleNode("/property/original");
if (xmlNode != null)
{
Match match = Regex.Match(xmlNode.InnerText, @"\d+");
if (match.Success)
{
return int.Parse(match.Value);
}
}
}
}
catch { }
return result;
}
}
}参考资料
[1].API代理商业务接口域名whois接口编码:http://www.net.cn/service/faq/other/sp/200611/1538.html
评论(0)
暂无评论。