我想从我的c#/ java程序中获取域名的whois信息.有一个简单的方法吗?
我在dotnet-snippets.com上找到了一个完美的C#示例(它不再存在).
这11行代码可以直接复制并粘贴到您自己的应用程序中.
////// Gets the whois information. /// /// The whois server. /// The URL. ///private string GetWhoisInformation(string whoisServer, string url) { StringBuilder stringBuilderResult = new StringBuilder(); TcpClient tcpClinetWhois = new TcpClient(whoisServer, 43); NetworkStream networkStreamWhois = tcpClinetWhois.GetStream(); BufferedStream bufferedStreamWhois = new BufferedStream(networkStreamWhois); StreamWriter streamWriter = new StreamWriter(bufferedStreamWhois); streamWriter.WriteLine(url); streamWriter.Flush(); StreamReader streamReaderReceive = new StreamReader(bufferedStreamWhois); while (!streamReaderReceive.EndOfStream) stringBuilderResult.AppendLine(streamReaderReceive.ReadLine()); return stringBuilderResult.ToString(); }