总结:
建立一个whois查询需要以下几步:
1) 用 Imports 语句导入 System,,System.Net,System.IO 和System.Net.Sockets名字空间
2) 用TcpClient 类连接whois远程服务器
送出我们的域名查询
3) 得到WHOIS服务器反应的信息
4) 显示数据
5) 另外,用try catch对 SocketException 类的异常事件进行处理。
注意:在我提供的下拉表中提供了四个常用的whois服务器
whois.cnnic.net.cn (.cn) 查询cn域名
whois.networksolutions.com (.COM, .NET, .EDU)
whois.ripe.net(欧洲)
whois.arin.net(美洲)
互联网日新月异,变化太快,这里是一份whois服务器列表http://wmjie.51.net/swords/blog/index.php?action=show&id=104
已经包含了100多个whois服务器查询网址,你可自行进行添加到DropDownList列表中。
代码清单:
<%@ Page Language="VB" Debug="true" %>
<% @Import Namespace=System %>
<% @Import Namespace=System.Net %>
<% @Import Namespace=System.IO %>
<% @Import Namespace=System.Net.Sockets %>
<script runat="server">
sub querywhois(obj as object, e as EventArgs)
Dim WhoIsClient As New TcpClient()
Dim WhoIsStream As NetworkStream
Dim WhoIsWriter As StreamWriter
Dim WhoIsReader As StreamReader
Dim Hostname as string
try
Hostname=request.form("domainname") & vbcrlf
WhoIsClient.Connect(request.form("WhoisServer"), 43)
WhoIsStream = WhoIsClient.GetStream()
WhoIsWriter = New StreamWriter(WhoIsStream)
WhoIsWriter.Write(Hostname)
WhoIsWriter.Flush()
WhoIsReader = New StreamReader(WhoIsStream)
lblResponse.Text = "<pre>"
lblResponse.text+="<br><br>Whois.Aspx 查询系统 by swords[E.S.T]<br>" & _
"welcome to my studio:<a href=http://wmjie.51.net/swords target=new>Savor.swords studio</a><br><br>"
while whoisreader.peek() > -1
lblResponse.text+=server.HTMLEncode(WhoIsReader.ReadLine) & "<br>"
end while
lblResponse.text+="</pre>"
WhoIsStream.Close()
WhoIsClient.Close()
catch ex as Exception
lblResponse.Text = ex.message
end try
end sub
</script>
<html>
<head>
<style>
.main {font-family:Verdana; font-size:15px;}
.title {font-family:Verdana; font-size:18px; font-weight:bold;}
</style>
</head>
<body>
<div class="title" align="center">Whois.Aspx 查询系统 by swords[E.S.T]</div>
<form method="POST" name="MainForm" runat="server">
<table>
<tr>
<td class="main" align="right">请选择查询Whois所用的服务器</td>
<td class="main">
<asp:DropDownList class="main" id="WhoisServer" runat="server">
<asp:ListItem value="whois.cnnic.net.cn">whois.cnnic.net.cn (.cn)</asp:ListItem>
<asp:ListItem value="whois.networksolutions.com">whois.networksolutions.com (.COM, .NET, .EDU)</asp:ListItem>
<asp:ListItem value="whois.ripe.net">whois.ripe.net(欧洲)</asp:ListItem>
<asp:ListItem value="whois.arin.net">whois.arin.net(美洲)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="main" align="right">查询的域名或IP地址:</td>
<td class="main"><input type="text" class="main" name="DomainName" value="swords.cn"></td>
</tr>
<tr>
<td class="main"> </td>
<td class="main"><input type="Submit" id="btnSubmit" OnServerClick="querywhois" value="开始查询" runat="server" /></td>
</tr>
</table>
<br><br>
<asp:Label class="main" id="lblResponse" runat="server"/>
</form>
</body>
</html>
测试:
看到了吗?查询后的结果显示了详细的信息,Success! Cheers!
| 如何针对Yahoo搜索进行网站优化 | 04-04 | |
| 搜索引擎不收录网站页面的15个原 | 04-04 | |
| 网站推广29大法 | 04-04 | |
| 搜索引擎优化培训教程 | 04-02 | |
| 彻底弄懂CSS盒子模式(DIV布局快速 | 03-19 | |
| Google优化圣经 | 03-19 | |
| 新网站流量快速提高实战 | 02-07 | |
| 2007年,个人站长将何去何从? | 02-03 | |
| 个人网站到底应该做什么样的广告 | 01-29 | |
| 王通:网站的首页最应该放什么? | 01-25 | |
| 百度与站长:关于网站收录删除和 | 01-04 | |
| 搜索引擎对页面各元素的权重比例 | 12-26 | |