コード例 #1
0
ファイル: ProxyPool.cs プロジェクト: wuyou201400/DotnetSpider
        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
ファイル: Site.cs プロジェクト: GamesDesignArt/DotnetSpider
		/// <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
ファイル: ProxyPool.cs プロジェクト: yalunwang/DotnetSpider
        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
        }