功能:批量解析域名,批量查询网页可否访问。
使用方法:导入指定格式EXCEL表格,工具开始自动解析。
代码片段:
//解析域名并填表
int ResErrCount=0;
int WebErrCount = 0;
for (int i = 0; i < dataGridView1.Rows.Count-1; i++)
{
try
{
//解析主机名
IPHostEntry IPinfo = Dns.GetHostEntry(dataGridView1.Rows[i].Cells[0].Value.ToString());
//填入表格
foreach (IPAddress IP in IPinfo.AddressList)
{
dataGridView1.Rows[i].Cells[2].Value = dataGridView1.Rows[i].Cells[2].Value + " " + IP.ToString();
}
}
catch
{
ResErrCount++;
}
//访问网页
try
{
WebClient myWebClient = new WebClient();
myWebClient.OpenRead(dataGridView1.Rows[i].Cells[1].Value.ToString());
dataGridView1.Rows[i].Cells[3].Value = "网页可访问";
}
catch
{
WebErrCount++;
}
if (ResErrCount > 0 || WebErrCount>0)
showInfo("解析失败个数:" + ResErrCount + " 网页访问失败个数:" + WebErrCount);
}
源码下载地址:https://download.csdn.net/download/dt236688160/13729382