Esempio n. 1
0
 public CollectionWorker(GatherForTrain bot, String name,
         int year)
 {
     this.bot = bot;
     this.name = name;
     this.year = year;
     this.search = new YahooSearch();
 }
Esempio n. 2
0
 public CollectionWorker(GatherForTrain bot, String name,
                         int year)
 {
     this.bot    = bot;
     this.name   = name;
     this.year   = year;
     this.search = new YahooSearch();
 }
    static void Main()
    {
        foreach (int page in new[] { 0, 1 })
        {
            YahooSearch x = new YahooSearch("test", page);

            foreach (YahooResult result in x.Results)
            {
                Console.WriteLine(result);
            }
        }
    }
Esempio n. 4
0
    static void Main()
    {
        foreach (int page in new[] { 0, 1 })
        {
            YahooSearch x = new YahooSearch("test", page);

            foreach (YahooResult result in x.Results)
            {
                Console.WriteLine(result);
            }
        }
    }
Esempio n. 5
0
        /// <summary>
        /// This method is called to determine the birth year for a person. It
        /// obtains 100 web pages that Yahoo returns for that person. Each of these
        /// pages is then searched for the birth year of that person. Which ever year
        /// is selected the largest number of times is selected as the birth year.
        /// </summary>
        /// <param name="name">The name of the person you are seeing the birth year for.</param>
        public void Process(String name)
        {
            search = new YahooSearch();

            if (YearBornBot.LOG)
            {
                Console.WriteLine("Getting search results form Yahoo.");
            }
            ICollection <Uri> c = search.Search(name);
            int i = 0;

            if (YearBornBot.LOG)
            {
                Console.WriteLine("Scanning URL's from Yahoo.");
            }

            int resultYear = -1;

            foreach (Uri u in c)
            {
                Console.Write("Scanning URL #1:");
                i++;
                Text.CheckURL(this, u, 0);
                resultYear = GetResult();
                if (resultYear == -1)
                {
                    Console.WriteLine(" no result so far.");
                }
                else
                {
                    Console.WriteLine(" may have been born in " + resultYear);
                }
            }

            resultYear = GetResult();
            if (resultYear == -1)
            {
                Console.WriteLine("Could not determine when " + name
                                  + " was born.");
            }
            else
            {
                Console.WriteLine(name + " was born in " + resultYear);
            }
        }
        public void TestGetJson()
        {
            search = new YahooSearch(parameter, apiKey);
            JObject data = search.GetJson();

            Assert.AreEqual(data["search_metadata"]["status"], "Success");

            // access organic results
            JArray coffeeShops = (JArray)data["organic_results"];

            Assert.IsNotNull(coffeeShops);
            // print the name of all coffee shop
            foreach (JObject coffeeShop in coffeeShops)
            {
                Console.WriteLine("Found: " + coffeeShop["title"]);
                Assert.IsNotNull(coffeeShop["title"]);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// This method is called to determine the birth year for a person. It
        /// obtains 100 web pages that Yahoo returns for that person. Each of these
        /// pages is then searched for the birth year of that person. Which ever year
        /// is selected the largest number of times is selected as the birth year.
        /// </summary>
        /// <param name="name">The name of the person you are seeing the birth year for.</param>
        public void Process(String name)
        {
            search = new YahooSearch();

            if (YearBornBot.LOG)
            {
                Console.WriteLine("Getting search results form Yahoo.");
            }
            ICollection<Uri> c = search.Search(name);
            int i = 0;

            if (YearBornBot.LOG)
            {
                Console.WriteLine("Scanning URL's from Yahoo.");
            }

            int resultYear = -1;

            foreach (Uri u in c)
            {
                Console.Write("Scanning URL #1:");
                i++;
                Text.CheckURL(this, u, 0);
                resultYear = GetResult();
                if (resultYear == -1)
                {
                    Console.WriteLine(" no result so far.");
                }
                else
                {
                    Console.WriteLine(" may have been born in " + resultYear);
                }

            }

            resultYear = GetResult();
            if (resultYear == -1)
            {
                Console.WriteLine("Could not determine when " + name
                        + " was born.");
            }
            else
            {
                Console.WriteLine(name + " was born in " + resultYear);
            }

        }