示例#1
0
        public static void Main(string[] args)
        {
            ProxyPool proxyPool = new ProxyPool(GetProxyList());

            proxyPool.SetReuseInterval(10000);
            proxyPool.SaveProxyList();

            while (true)
            {
                List <HttpHost> httphostList = new List <HttpHost>();
                Console.Read();
                int i = 0;
                while (proxyPool.GetIdleNum() > 2)
                {
                    HttpHost httphost = proxyPool.GetProxy();
                    httphostList.Add(httphost);
                    // proxyPool.proxyPool.use(httphost);
                    //Logger.Info("borrow object>>>>" + i + ">>>>" + httphostList[i]);
                    i++;
                }
                Console.WriteLine(proxyPool.AllProxyStatus());
                Console.Read();
                for (i = 0; i < httphostList.Count; i++)
                {
                    proxyPool.ReturnProxy(httphostList[i], 200);
                    //Logger.Info("return object>>>>" + i + ">>>>" + httphostList[i]);
                }
                Console.WriteLine(proxyPool.AllProxyStatus());
                Console.Read();
            }
            // ReSharper disable once FunctionNeverReturns
        }
示例#2
0
		/// <summary>
		/// add http proxy , string[0]:ip, string[1]:port
		/// </summary>
		/// <param name="httpProxyList"></param>
		/// <returns></returns>
		public Site AddHttpProxies(List<string[]> httpProxyList)
		{
			_httpProxyPool = new ProxyPool(httpProxyList);
			return this;
		}
示例#3
0
        public static void Main(string[] args)
        {
            ProxyPool proxyPool = new ProxyPool(GetProxyList());
            proxyPool.SetReuseInterval(10000);
            proxyPool.SaveProxyList();

            while (true)
            {
                List<HttpHost> httphostList = new List<HttpHost>();
                Console.Read();
                int i = 0;
                while (proxyPool.GetIdleNum() > 2)
                {
                    HttpHost httphost = proxyPool.GetProxy();
                    httphostList.Add(httphost);
                    // proxyPool.proxyPool.use(httphost);
                    //Logger.Info("borrow object>>>>" + i + ">>>>" + httphostList[i]);
                    i++;
                }
                Console.WriteLine(proxyPool.AllProxyStatus());
                Console.Read();
                for (i = 0; i < httphostList.Count; i++)
                {
                    proxyPool.ReturnProxy(httphostList[i], 200);
                    //Logger.Info("return object>>>>" + i + ">>>>" + httphostList[i]);
                }
                Console.WriteLine(proxyPool.AllProxyStatus());
                Console.Read();
            }
            // ReSharper disable once FunctionNeverReturns
        }