コード例 #1
0
ファイル: App.cs プロジェクト: krishnad1982/AbcScraper
        public void Run()
        {
            if (!string.IsNullOrEmpty(IsValid(_config)))
            {
                return;
            }
            try
            {
                Dictionary <string, List <ScraperResult> > result = new Dictionary <string, List <ScraperResult> >();
                foreach (var scraper in _config.ScraperSettings)
                {
                    result.TryAdd(scraper.Provider.ToString(), _scraperService.GetUrlPosition(scraper.SearchKeyWords,
                                                                                              scraper.PageNumbers, scraper.Provider, LookUpUrl));
                }

                foreach (KeyValuePair <string, List <ScraperResult> > entry in result)
                {
                    Console.WriteLine($"Result for provider: {entry.Key}");

                    foreach (var scrapeResult in entry.Value)
                    {
                        var Positions = string.IsNullOrEmpty(scrapeResult.Positions) ? "0" : scrapeResult.Positions;
                        Console.WriteLine($"Total number of positions: {Positions} for the keyword: {scrapeResult.Keyword}");
                    }
                    Console.WriteLine($".............End Provider: {entry.Key}....................");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Something went wrong");
            }
        }