Search code examples
c#apiscreen-scrapinggoogle-search-api

How to return exact google search results?


I'm working on a c# application to return the exact top 10 Google search results for a specific keyword. So I decided to try the Google search api. In particular, I'm using a dotnet application called "GoogleSearchAPI", but it doesn't return the exact same results as typing into Google & I'm curious if there's a way to do so. Either using the Google Search API or through some other method, I really don't care which way.

For example, here are 2 screenshots using the same search phrase. 1st one is from google: enter image description here

And this one is what's being returned from Google Search API for the same search phrase (this image looks squished in my preview while writing this, so just in case, here's the image url: image link): enter image description here

As you can see, the api is returning very different results. The 1st google search return is google plus. The api returns the actual website. Then, the api returns 3 facebook results, where as google returns yelp. Very different.

Here's the sample code I used in the GoogleSearchAPI:

WebQuery query = new WebQuery(tbQuery.Text);
        query.ResultSetSize.Value = ResultSetSize.large;
        IGoogleResultSet<GoogleWebResult> resultSet = GoogleService.Instance.Search<GoogleWebResult>(query);
        dgvResults.DataSource = resultSet.Results;

Does anyone know how I can retrieve the exact search results Google returns? I can always resort to scraping but it's against Google's terms, so I'd need to create workarounds and it becomes rather messy, so I'd prefer to avoid that if I can.

Thanks


Solution

  • If you are getting the result from API is everything Ok. You cant get same resut from google search everything is based on your cookies, browser history, bookmarks, location etc. You can try searching from two different browser you will get different results.