示例#1
0
        public async Task Run()
        {
            Console.Write("What is your search term? ");
            var searchCriteria = Console.ReadLine();

            while (String.IsNullOrWhiteSpace(searchCriteria) || String.IsNullOrWhiteSpace(searchCriteria.StripNonAlphanumeric()))
            {
                Console.Write("That is not a valid term, please try again: ");
                searchCriteria = Console.ReadLine();
            }
            var content = await _searcher.GetContent(searchCriteria);

            if (String.IsNullOrWhiteSpace(content))
            {
                Console.WriteLine("Unable to make google request. Please try again.");
            }
            else
            {
                var matchesResult = _matchFinder.FindPositions(content, _config["companyDetails:url"]);
                Console.WriteLine($"We found your site {_config["companyDetails:url"]} in the following positions (Zero means not found at all): {matchesResult}");
            }
        }