How to do a Google search with C #?

1

I need to fetch any term on Google and get a list of the results of that search. I'm trying to do this using the Google Custom Search API but I'm not getting satisfactory results.

For example, when I search for the term "bidding" with my code I get 1,510,000 results. When I search for the same direct term in the browser I get 11,800,000 results.

How do I get all 11,800,000 from this survey?

Below is my code in C #:

 static void Main(string[] args)
    {
        string apiKey = "AIzaSyCVGlnfsGaaJ3HYTHVu6OH_jBaIFJQYrH0";
        string cx = "013638634553566051485:xwnfxqp2pso";
        string query = "licitações";
        var svc = new Google.Apis.Customsearch.v1.CustomsearchService(
        new BaseClientService.Initializer { ApiKey = apiKey });
        var listRequest = svc.Cse.List(query);
        listRequest.Cx = cx;
        var search = listRequest.Execute(); //listRequest.Fetch(); This method has been removed
        foreach (var result in search.Items)
        {
            Console.WriteLine("Title: {0}", result.Title);
            Console.WriteLine("Link: {0}\n", result.Link);
        }
        Console.ReadKey();
    }
    
asked by anonymous 20.10.2016 / 19:56

1 answer

1

Unfortunately, or fortunately, the numbers are different for a few reasons.

Custom Search vs. Google.com

In general, a custom search engine searches through a site collection that you specify. However, you can set up your custom search engine to search the entire web. In this case, however, the results are unlikely to match those returned by Google Web Search, for several reasons:

  • Although a custom search engine is set up to search the entire Web, it is designed to highlight the results of your sites.
  • Your custom search engine does not include Google Web Search functions such as OneBox, real-time search results, universal search, social functions, or custom results.
  • If your custom search engine includes more than ten sites, the results may come from a subset of our index and differ from the results of a "site:" search operator made on Google.com.

If you want to get more complete results from your custom search engine, try one of the following:

  • Search Preferences section Basics tab Control Panel, select Search only the included sites. Be sure not to include more than ten sites on the Sites tab. The domains you add to it will be included in the total count, but not the pages of the domains is taken into account.
  • Search Preferences section Basics tab Control Panel, select Search Web, but emphasize included places.
  • Add restricted to your search engine that fulfills one of these quests requirements.

We have a similar question on our "big brother , if you'd like to check out.

  

Note: The text has been translated using Google Translate, so it may contain some translation errors. The original text can be found this link .

    
20.10.2016 / 21:55