How to Force Google to Show “total_results” When Scraping

hartator
SerpApi
Published in
3 min readSep 18, 2019

Users of our Google scraping API have noticed that certain queries don’t return the total_results property that you would normally see on the top left side of the Google interface.

Google total results property
Google results showing “total_results” value

The total_results property is a number returned by Google that represents the total number of results in the result set of that particular query. That number is just an approximation and may not represent the exact number of results, nor will Google allow you to retrieve all those results — you can read more on that in our documentation regarding pagination.

Our API allows a user to scrape Google for the total_results property and will return a number value in JSON format, as shown in the example below.

API returned JSON format with “total_results” property and value

What happens when Google doesn’t return the total_results value for a particular search? An example of a query that won’t return the “total_results” property is “SQL Entwickler,” which we will be using for our example. You can follow along in this example by using our playground.

Notice when searching “SQL Entwickler,” Google fails to return a value for the total_results property.

Google search results indicating missing “total_results” value

You will also notice that our API did not return a value for the total_results property.

API returned JSON format without “total_results” property and value

To override this issue, we will navigate to our playground and set the pagination parameter to a value of “1.” Set your search query to the same value of “SQL Entwickler.” Hit the search button when all your parameters are set.

SerpApi Playground showing “pagination” value

Navigate over to the top right corner of the page in the playground and click “Export to Code,” which will provide you with the results of your query. As you will notice, you are provided with URLs for results in both HTML and JSON format. Navigate to either URL and you will notice that the total_results value is displayed.

Links to API results

The returned results now include the total_results value displayed in its usual place, as expected.

API results in HTML format

Our API returned also returned the missing total_results value in JSON as well.

API results in JSON format

What appears to have happened is that either the first or second SERP result may have triggered some other informational property to show up, and somehow replace the total_results property on Google. Nonetheless, this fix works perfectly fine.

Visit SerpAPI for additional information on our app and try different configurations and searches utilizing our playground.

--

--

hartator
SerpApi

Passion for beautiful code, lunatic enterprises and ludicrous dreams