static void Main(string[] args) { Console.WriteLine( "*** Extração de Dados da Web com " + ".NET Core 2.1, Selenium WebDriver e DocumentDB ***"); Console.WriteLine("Carregando configurações..."); var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile($"appsettings.json"); var configuration = builder.Build(); _seleniumConfigurations = new SeleniumConfigurations(); new ConfigureFromConfigurationOptions <SeleniumConfigurations>( configuration.GetSection("SeleniumConfigurations")) .Configure(_seleniumConfigurations); _documentDBConfigurations = new DocumentDBConfigurations(); new ConfigureFromConfigurationOptions <DocumentDBConfigurations>( configuration.GetSection("DocumentDBConfigurations")) .Configure(_documentDBConfigurations); ExtrairDadosCampeonato("Brasileirão", "Brasil", _seleniumConfigurations.UrlPaginaClassificacaoBrasileirao); ExtrairDadosCampeonato("La Liga", "Espanha", _seleniumConfigurations.UrlPaginaClassificacaoLaLiga); ExtrairDadosCampeonato("Premier League", "Inglaterra", _seleniumConfigurations.UrlPaginaClassificacaoPremierLeague); Console.WriteLine( Environment.NewLine + "Carga de dados concluída com sucesso!"); Console.ReadKey(); }
public ClassificacaoRepository( DocumentDBConfigurations configurations) { _configurations = configurations; _client = new DocumentClient( new Uri(configurations.EndpointUri), configurations.PrimaryKey); // Cria o banco de dados caso o mesmo não exista _client.CreateDatabaseIfNotExistsAsync( new Database { Id = configurations.Database }).Wait(); // Cria a coleção caso a mesma não exista DocumentCollection collectionInfo = new DocumentCollection(); collectionInfo.Id = _configurations.Collection; collectionInfo.IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 }); _client.CreateDocumentCollectionIfNotExistsAsync( UriFactory.CreateDatabaseUri(_configurations.Database), collectionInfo, new RequestOptions { OfferThroughput = 400 }).Wait(); }