Exemplo n.º 1
0
            protected virtual IProxyUriLoader CreateProxyUriLoader(string dbConfigName)
            {
                DefaultProxyUriLoader loader = new DefaultProxyUriLoader()
                {
                    DbContextFactory = () => ProxyDbContext.CreateInstance(dbConfigName),
                    Days             = 360,
                    Condition        = e => e.Category == 1 && e.AnonymityDegree == 3
                };

                return(loader);
            }
Exemplo n.º 2
0
            protected virtual IProxyUriLoader CreateProxyUriLoader()
            {
                DefaultProxyUriLoader loader = new DefaultProxyUriLoader()
                {
                    Days             = 360,
                    Condition        = e => e.Category == 1 && e.AnonymityDegree == 3,
                    DbContextFactory = () => ProxyDbContext.CreateInstance("SqlServerTest")
                };

                return(loader);
            }
Exemplo n.º 3
0
            protected virtual IProxyUriLoader CreateProxyUriLoader()
            {
                DefaultProxyUriLoader loader = new DefaultProxyUriLoader()
                {
                    Days             = 360,
                    DbContextFactory = () => ProxyDbContext.CreateInstance(),
                    EntityOption     = new SpiderProxyUriEntityOption()
                    {
                        Category = 1, AnonymityDegree = 3, ResponseMilliseconds = 10000
                    }
                };

                return(loader);
            }
Exemplo n.º 4
0
        public override async Task RunAsync()
        {
            string caseName = ClassName;
            var    pa       = ProxyDbContext.CreateInstance();
            string url      = ApiProvider.GetRequestUrl();

            using var client = ApiProvider.CreateWebClient();
            var entities = await GetProxyEntitiesAsync(client, HttpMethod.Get, url);

            if (entities.Count < 1)
            {
                return;
            }
            entities.ForEach(e => e.Source = caseName);
            ShowLogInfo("CollectCount: " + entities.Count.ToString());
            int insertCount = pa.InsertProxyEntities(entities);

            ShowLogInfo("InsertCount: " + insertCount.ToString());
        }
Exemplo n.º 5
0
        public override async Task RunAsync()
        {
            DefaultProxyUriLoader proxyUriLoader = new DefaultProxyUriLoader()
            {
                Days             = 360,
                DbContextFactory = () => ProxyDbContext.CreateInstance()
            };
            DefaultWebProxyValidator webProxyValidator = new DefaultWebProxyValidator(CreateWebClient, ValidateWebProxy, new WebProxyValidatorConfig()
            {
                UseThresold         = 1,
                VerifyPauseThresold = 2
            });
            DefaultWebProxySelector proxySelector = new DefaultWebProxySelector(new Uri("http://www.baidu.com"), proxyUriLoader, webProxyValidator);

            proxySelector.Initialize();
            string rspText = await HttpConsole.GetResponseTextByProxyAsync(HomePageUri, proxySelector, GetResponseTextAsync).ConfigureAwait(false);

            ShowLogInfo(rspText);
        }