提取 whois 信息,并把相关内容存进数据库~

坤哥zzz 2009-03-23 02:07:34
通过百度关键字搜索,找到带有"推广"内容的公司的域名,并通过whois查询域名注册信息,把注册信息存在数据库里~

我现在已经把所有域名都取出来,哪位高手能告诉我怎么通过域名查询whois信息,并把信息存入数据库啊~
...全文
229 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
坤哥zzz 2009-03-24
  • 打赏
  • 举报
回复
Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

Domain Name: MITSUBISHIZINGER.COM
Registrar: XIAMEN CHINASOURCE INTERNET SERVICE CO., LTD.
Whois Server: whois.cnolnic.com
Referral URL: http://www.zzy.cn
Name Server: NS1.CNOLNIC.COM
Name Server: NS2.CNOLNIC.COM
Status: clientTransferProhibited
Updated Date: 30-jul-2008
Creation Date: 30-jul-2008
Expiration Date: 30-jul-2010

>>> Last update of whois database: Tue, 24 Mar 2009 04:31:47 UTC <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.



像这样的怎么把这点东西取出来啊~

Domain Name: MITSUBISHIZINGER.COM
Registrar: XIAMEN CHINASOURCE INTERNET SERVICE CO., LTD.
Whois Server: whois.cnolnic.com
Referral URL: http://www.zzy.cn
Name Server: NS1.CNOLNIC.COM
Name Server: NS2.CNOLNIC.COM
Status: clientTransferProhibited
Updated Date: 30-jul-2008
Creation Date: 30-jul-2008
Expiration Date: 30-jul-2010

我现在就是不知道怎么把东西取出来,然后存进数据库~(假设数据库里有字段了)
坤哥zzz 2009-03-24
  • 打赏
  • 举报
回复
谢谢,whois信息取出来了~

我现在想知道怎么从whois信息中取出各种字段,插入数据库

例如: domain:.....
name:...
date:...
occam 2009-03-24
  • 打赏
  • 举报
回复
每个server返回的格式似乎是不相同的,自己分析咯
tianke3477 2009-03-24
  • 打赏
  • 举报
回复
分析html,就和采集程序一样
qlzf11140820 2009-03-24
  • 打赏
  • 举报
回复
up
坤哥zzz 2009-03-24
  • 打赏
  • 举报
回复
不好意思,我是个新手!

做法我明白,但是不会写,你能给我写下吗?
就是把下面这些值取出来~
Domain Name: MITSUBISHIZINGER.COM
Registrar: XIAMEN CHINASOURCE INTERNET SERVICE CO., LTD.
Whois Server: whois.cnolnic.com
Referral URL: http://www.zzy.cn
Name Server: NS1.CNOLNIC.COM
Name Server: NS2.CNOLNIC.COM
Status: clientTransferProhibited
Updated Date: 30-jul-2008
Creation Date: 30-jul-2008
Expiration Date: 30-jul-2010
occam 2009-03-24
  • 打赏
  • 举报
回复
indexof查找substring取子串,或者用正则表达式查找匹配
occam 2009-03-23
  • 打赏
  • 举报
回复
public static bool LookupWHOISRegistry(string domain, out string registrytext)
{
if (string.IsNullOrEmpty(domain) || domain.IndexOf('.') == -1)
{
registrytext = "Invalid domain name";
return false;
}
domain = domain.Trim().ToLower();

bool result;

// determine whois server
string serverDomain;
switch (domain.Substring(domain.LastIndexOf('.') + 1))
{
case "cn":
if (domain.EndsWith(".edu.cn"))
serverDomain = "whois.edu.cn";
else
serverDomain = "whois.cnnic.net.cn";
break;
case "com":
case "net":
serverDomain = "whois.internic.net";
break;
case "org":
serverDomain = "whois.pir.org";
break;
case "nfo":
serverDomain = "whois.afilias.info";
break;
case "biz":
serverDomain = "whois.biz";
break;
case "cc":
case "tv":
serverDomain = "whois.nic.cc";
break;
case "edu":
serverDomain = "whois.internic.net";
break;
case "gov":
serverDomain = "whois.larc.nasa.gov";
break;
default:
serverDomain = null;
break;
}

Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
clientSocket.Connect(new IPEndPoint(Dns.GetHostEntry(serverDomain).AddressList[0], 43));

if (clientSocket.Connected)
{
StringBuilder data = new StringBuilder(512);
string httpRequestString = string.Format("{0}\nConnection: Close\n", domain);
clientSocket.Send(Encoding.ASCII.GetBytes(httpRequestString));

byte[] receiveBuffer = new byte[256];
int byteCount;

do
{
byteCount = clientSocket.Receive(receiveBuffer, 256, 0);
data.Append(Encoding.UTF8.GetString(receiveBuffer, 0, byteCount));
} while (byteCount > 0);

registrytext = data.ToString();
result = (registrytext.IndexOf("no match") != -1 && registrytext.IndexOf("not found") != -1);
}
else
{
registrytext = "Cannot connect to WHOIS server";
result = false;
}

}
catch (Exception e)
{
registrytext = e.Message;
result = false;
}
finally
{
clientSocket.Close();
}

return result;
}

前两年写的,域名也没全测试过,不过.com和.net没什么问题
也不知道那些服务器还能用不...
quanzi0214 2009-03-23
  • 打赏
  • 举报
回复
http://www.whois.net/whois/要查询的域名
模拟http请求提交到这个页面!
用正则匹配出你要存储的内容!
附上c#的get请求方式
private string GetModel(string strUrl)
{
string strRet = null;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
request.Timeout = 2000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
System.IO.Stream resStream = response.GetResponseStream();
Encoding encode = System.Text.Encoding.Default;
StreamReader readStream = new StreamReader(resStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
strRet = strRet + str;
count = readStream.Read(read, 0, 256);
}
resStream.Close();
}
catch (Exception e)
{
strRet = "";
}
return strRet;
}
坤哥zzz 2009-03-23
  • 打赏
  • 举报
回复
查我也会查,问题是怎么写代码?
quanzi0214 2009-03-23
  • 打赏
  • 举报
回复
去http://www.whois.net/
查询

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧