資源簡介
代碼來源于CSDN,但是那個代碼有很多錯誤都被我修改了,軟件使用快代理的VIP功能獲取代理IP,并獲取指定地區IP,并多線程測試是否可用(項目完整并可運行)且使用多線程做校驗
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Net;
using?System.IO;
using?System.Text.Regularexpressions;
using?System.Collections;
using?System.Threading;
namespace?Proxy
{
????public?partial?class?Form1?:?Form
????{
????????private?DataTable?dt?=?new?DataTable();
????????private?Queue?urlList?=?new?Queue();
????????private?Queue?ipList?=?new?Queue();
????????private?delegate?void?addRowDelegate(object[]?obj);//定義委托
????????private?delegate?void?updateRowDelegate(string?str);
????????Thread?myThread;
????????private?int?id?=?0;
????????private?int?currentIndex?=?0;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????myThread?=?new?Thread(downLoad);//實例化線程
????????????myThread.Start();//啟動線程
???????????
????????}
????????private?void?downLoad()
????????{
????????????urlList.Enqueue(“http://www.ipfree.cn/index2-1.html“);
????????????urlList.Enqueue(“http://www.ipfree.cn/index2-2.html“);
????????????urlList.Enqueue(“http://www.ipfree.cn/index2-3.html“);
????????????urlList.Enqueue(“http://www.ipfree.cn/index2-4.html“);
????????????urlList.Enqueue(“http://www.ipfree.cn/index2-5.html“);
????????????while?(urlList.Count?>?0)
????????????{
????????????????System.Net.ServicePointManager.DefaultConnectionLimit?=?100;
????????????????//??WebPageState?state?=?new?WebPageState(“http://www.ipfree.cn/index2-1.html“);
????????????????WebPageState?state?=?new?WebPageState(urlList.Dequeue().ToString());
????????????????state.ProcessStarted?=?true;
????????????????state.ProcessSuccessfull?=?false;
????????????????WebResponse?res?=?null;
????????????????try
????????????????{
????????????????????//?Console.WriteLine(“[?“?+?DateTime.Now?+?“?][?“?+?Thread.CurrentThread.Name?+?“?]:?“?+?“{0}?Download?Start:?{1}“?+?“總下載:“?+?Fron.Common.AppPara.DownLoadCount?state.Uri.ToString()?state.ProcessSuccessfull);
????????????????????//WebProxy?proxy?=?new?WebProxy();
????????????????????System.Net.HttpWebRequest?req?=?(System.Net.HttpWebRequest)WebRequest.Create(state.Uri);
????????????????????req.ServicePoint.ConnectionLimit?=?500;
????????????????????//proxy.Address?=?new?Uri(“http://219.150.144.58:80“);
????????????????????//req.Headers.Add(“VIA“?““);
????????????????????//req.Headers.Add(“X_FORWARDED_FOR“?““);
????????????????????//??req.Proxy?=?proxy;
????????????????????req.Timeout?=?600000;
????????????????????res?=?req.GetResponse();
????????????????????if?(res?is?HttpWebResponse)
????????????????????{
????????????????????????state.StatusCode?=?((HttpWebResponse)res).StatusCode.ToString();
????????????????????????state.StatusDescription?=?((HttpWebResponse)res).StatusDescription;
????????????????????}
????????????????????if?(res?is?Fi
- 上一篇:rdlc報表表達式應用(字符串和轉換)
- 下一篇:bmp轉化565或888C文件
評論
共有 條評論