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); }
protected virtual IProxyUriLoader CreateProxyUriLoader() { DefaultProxyUriLoader loader = new DefaultProxyUriLoader() { Days = 360, Condition = e => e.Category == 1 && e.AnonymityDegree == 3, DbContextFactory = () => ProxyDbContext.CreateInstance("SqlServerTest") }; return(loader); }
protected virtual IProxyUriLoader CreateProxyUriLoader() { DefaultProxyUriLoader loader = new DefaultProxyUriLoader() { Days = 360, DbContextFactory = () => ProxyDbContext.CreateInstance(), EntityOption = new SpiderProxyUriEntityOption() { Category = 1, AnonymityDegree = 3, ResponseMilliseconds = 10000 } }; return(loader); }
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()); }
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); }