|
楼主 |
发表于 2014-8-12 17:19:09
|
显示全部楼层
public void kaishi()
{
string[] wangzhi = File.ReadAllLines(textBox1.Text.Trim());//读取txt
string[] wenjianming = File.ReadAllLines(textBox2.Text.Trim());
int shuliang = (int)wangzhi.Length * (int)wenjianming.Length;//计算需要循环多少次
foreach (string wangzhi1 in wangzhi)//循环读取txt文件的内容
{
foreach (string wenjianming1 in wenjianming)
{
string strurl1 = "http://" + wangzhi1 + "/" + wenjianming1;
ThreadPool.QueueUserWorkItem(new WaitCallback(GetGeneralContent), strurl1);//创建一个线程池,并执行auto方法,strurl1是auto方法的参数
}
}
}
//public void qidong(object osvifo)
//{
// ServerInfo svinfo = (ServerInfo)osvifo;
// if (svinfo.powerBy.IndexOf("waf") != -1 )
// {
// return;
// }
//}
public void GetGeneralContent(object strUrl)
{
string strurl = strUrl as string;
string strMsg = string.Empty;
try
{
WebRequest request = WebRequest.Create(strurl);//链接浏览器
WebResponse response = request.GetResponse();//取链接返回内容
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
strMsg = reader.ReadToEnd();
if (strMsg.Contains("404 - Page Not Found"))//判断是否出现404
{
// richTextBox1.AppendText(strurl + " " + "[200]" + "\n");
}
else
{
richTextBox1.AppendText(strurl + " " + "[200]" + "\n");
}
reader.Close();
reader.Dispose();
response.Close();
}
catch
{ }
}
这是我的代码 |
|