资源简介

代码来源于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

评论

共有 条评论