日期:2014-05-18 浏览次数:21150 次
private void button1_Click_1(object sender, EventArgs e)
{
this.timer1.Enabled = true;
this.Paraments = this.textBox1.Text;
this.Cookies = this.textBox2.Text;
if (this.dt.Rows.Count == 0)
{
for (int i = begin; i <= end; i++)
{
DataRow dr = dt.NewRow();
dr["URL"] = this.text_url.Text.Replace("(*)", i.ToString());
dr["id"] = i.ToString();
this.dt.Rows.Add(dr);
}
this.dataGridView1.Refresh();
}
StopThread(Go_threads);
for (int i = 0; i < this.dt.Rows.Count; i++)
{
Go_threads[i] = new Thread(new ParameterizedThreadStart(Go_Thread));
//Go_threads[i].Name = "thread_" + i.ToString();
Go_threads[i].Start(i);
}
}
private void Go_Thread(object index)
{
int i = int.Parse(index.ToString());
string Url = dt.Rows[i]["URL"].ToString();
string parament = Paraments;
parament = parament.Replace("(*)", dt.Rows[i]["id"].ToString());
string cookies = Cookies;
HttpManager hm = new HttpManager(Url,parament,cookies);
string res = "";
res = hm.Post();
string html = hm.Data;
if (html != string.Empty)
{
if (html.Contains("文章不存在"))
{
res = "HasNotpage";
}
}
dt.Rows[i]["FLAG"] = res;
}
private void timer1_Tick(object sender, EventArgs e)
{
bool isOver = true;
for (int i = 0; i < Test_threads.Length; i++)
{
if (Test_threads[i] != null)
{
if (Test_threads[i].IsAlive)
{
if (Test_threads[i].ThreadState != ThreadState.Stopped)
{
isOver = false;
break;
}
}
}
}
for (int i = 0; i < Go_threads.Length; i++)
{
if (Go_threads[i] != null)
{
if (Go_threads[i].IsAlive)
{
if (Go_threads[i].ThreadState != ThreadState.Stopped)
{
isOver = false;
break;
}
}
}
}
if (isOver)
{
this.text_begin.Text = (int.Parse(this.text_begin.Text) - 2).ToString();
dt.Clear();
if (this.dt.Rows.Count == 0)
{
for (int i = begin; i <= end; i++)
{
DataRow dr = dt.NewRow();
dr["URL"] = this.text_url.Text.Replace("(*)", i.ToString());
dr["id"] = i.ToString();
this.dt.Rows.Add(dr);
}
this.dataGridView1.Refresh();
}
StopT