111,126
社区成员
发帖
与我相关
我的任务
分享
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();
}
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);
}
}
}
try
{
//Send request
Stream requestStream= this.req.GetRequestStream();
requestStream = this.req.GetRequestStream();
requestStream.Write(paramBytes, 0, paramBytes.Length);
requestStream.Close();
this.resp = (HttpWebResponse)this.req.GetResponse();
Encoding myEncoding = Encoding.Default;
if (this.resp.Headers["Content-Type"].Contains("utf-8"))
{
myEncoding = Encoding.GetEncoding("utf-8");
}
else if (this.resp.Headers["Content-Type"].Contains("GBK"))
{
myEncoding = Encoding.GetEncoding("GBK");
}
else if (this.resp.Headers["Content-Type"].Contains("GB2312"))
{
myEncoding = Encoding.GetEncoding("GB2312");
}
StreamReader myStreamReader = new StreamReader(new GZipStream( resp.GetResponseStream(),CompressionMode.Decompress),myEncoding);
this.data = myStreamReader.ReadToEnd();
myStreamReader.Close();
ret_str = "success";
return ret_str;
}
try
{
//Send request
Stream requestStream= this.req.GetRequestStream();
requestStream = this.req.GetRequestStream();
requestStream.Write(paramBytes, 0, paramBytes.Length);
requestStream.Close();
this.resp = (HttpWebResponse)this.req.GetResponse();
Encoding myEncoding = Encoding.Default;
if (this.resp.Headers["Content-Type"].Contains("utf-8"))
{
myEncoding = Encoding.GetEncoding("utf-8");
}
else if (this.resp.Headers["Content-Type"].Contains("GBK"))
{
myEncoding = Encoding.GetEncoding("GBK");
}
else if (this.resp.Headers["Content-Type"].Contains("GB2312"))
{
myEncoding = Encoding.GetEncoding("GB2312");
}
StreamReader myStreamReader = new StreamReader(new GZipStream( resp.GetResponseStream(),CompressionMode.Decompress),myEncoding);
this.data = myStreamReader.ReadToEnd();
ret_str = "success";
return ret_str;
}

MessageBox.Show("startStream" + url.ToString());
Stream requestStream= this.req.GetRequestStream();
MessageBox.Show("endStream" + url.ToString());this.req.ContentLength = paramBytes.Length;
this.req.ContentType = "application/x-www-form-urlencoded";
//Send request
Stream requestStream = this.req.GetRequestStream();
requestStream.Write(paramBytes, 0, paramBytes.Length);
requestStream.Close();this.req.ContentLength = paramBytes.Length;
this.req.ContentType = "application/x-www-form-urlencoded";
//Send request
Stream requestStream = this.req.GetRequestStream();
requestStream.Write(paramBytes, 0, paramBytes.Length);
requestStream.Close();