下面試用C#寫的,用頁面的URL,獲得IP地址:
因為一般的大網站可能會有多個IP的情況,所以得到的也可能會是多個IP。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace DNSIP
{
class Program
{
static void Main(string[] args)
{
String hostname = "www.baidu.com";
IPHostEntry host = Dns.GetHostEntry(hostname);
Console.WriteLine("GetHostEntry({0}) return: ", hostname);
foreach (IPAddress ip in host.AddressList)
{
Console.WriteLine(" {0}", ip);
}
Console.ReadKey();
}
}
}
google:多個返回IP

百度:只返回了一個IP,這裡的原因是我的代理是用的新加坡的。。
