Beispiel #1
0
        public void TestGetJson()
        {
            client = new GoogleSearchResultsClient(ht, apiKey);
            JObject data        = client.GetJson();
            JArray  coffeeShops = (JArray)data["local_results"]["places"];
            int     counter     = 0;

            foreach (JObject coffeeShop in coffeeShops)
            {
                Assert.IsNotNull(coffeeShop["title"]);
                counter++;
            }
            Assert.IsTrue(counter >= 1);

            coffeeShops = (JArray)data["organic_results"];
            Assert.IsNotNull(coffeeShops);
            foreach (JObject coffeeShop in coffeeShops)
            {
                Console.WriteLine("Found: " + coffeeShop["title"]);
                Assert.IsNotNull(coffeeShop["title"]);
            }

            // Release socket connection
            client.Close();
        }
Beispiel #2
0
        public void TestGetHtml()
        {
            client = new GoogleSearchResultsClient(ht, apiKey);
            string htmlContent = client.GetHtml();

            Assert.IsNotNull(htmlContent);
            //Console.WriteLine(htmlContent);
            Assert.IsTrue(htmlContent.Contains("</body>"));

            // Release socket connection
            client.Close();
        }