public PaginaClassificacao(
            SeleniumConfigurations configurations,
            string nomeCampeonato,
            string pais,
            string urlClassificacao)
        {
            _configurations   = configurations;
            _nomeCampeonato   = nomeCampeonato;
            _pais             = pais;
            _urlClassificacao = urlClassificacao;

            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--headless");

            _driver = new ChromeDriver(
                _configurations.CaminhoDriverChrome,
                options);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine(
                "*** Extração de Dados da Web com " +
                ".NET Core 2.2, Selenium WebDriver, " +
                "Chrome Driver e MongoDB ***");
            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);

            _mongoDBConfigurations = new MongoDBConfigurations();
            new ConfigureFromConfigurationOptions <MongoDBConfigurations>(
                configuration.GetSection("MongoDBConfigurations"))
            .Configure(_mongoDBConfigurations);

            ExtrairDadosCampeonato("Bundesliga", "Alemanha",
                                   _seleniumConfigurations.UrlPaginaClassificacaoBundesliga);
            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();
        }