Exemple #1
0
        /// <summary>
        /// This method counts the occurrences of the words. -w option
        /// </summary>
        /// <param name="url">the URL to scrap</param>
        private static void executeWordCount(String url)
        {
            WebScraper ws = null;

            if (WebScraperList.ContainsKey(url))
            {
                ws = WebScraperList[url];
            }
            else
            {
                ws = new WebScraper(url);
                WebScraperList.Add(url, ws);
            }

            if (GlobalOption.InputWords == null || GlobalOption.InputWords.Length == 0)
            {
                Console.WriteLine("There are no input words.");
                return;
            }

            int[] wordCount = ws.countWords(GlobalOption.InputWords);

            for (int i = 0; i < GlobalOption.InputWords.Length; i++)
            {
                Console.WriteLine("Count of word \"{1}\": {0}", wordCount[i], GlobalOption.InputWords[i]);
            }
        }
Exemple #2
0
        /// <summary>
        /// This method counts the characters in the HTML file. -c option
        /// </summary>
        /// <param name="url">the URL to scrap</param>
        private static void executeCharacterCount(String url)
        {
            WebScraper ws = null;

            if (WebScraperList.ContainsKey(url))
            {
                ws = WebScraperList[url];
            }
            else
            {
                ws = new WebScraper(url);
                WebScraperList.Add(url, ws);
            }

            int characterCount = ws.countCharacters();

            Console.WriteLine("Count of characters: {0}", characterCount);
        }