public-roadmap icon indicating copy to clipboard operation
public-roadmap copied to clipboard

[Google Product Result API] Update the search query in the documentation

Open martin-serpapi opened this issue 2 years ago • 2 comments

A customer reported that the code generated from the Google Product Result API documentation page results in a KeyError: 'product_result' after executing it. There is no longer a product_result returned in the results when searching for "iphone 11 pro":

image

Playground | Inspect

There's a product_result returned in the response when searching for "iphone 15 pro max":

image

Playground | Inspect

Intercom

martin-serpapi avatar Dec 07 '23 14:12 martin-serpapi

Hmm, perhaps there's a more stable product that could be used than a specific numbered iPhone model that's going to go out of date again in a few years?

How about "Montblanc Meisterstück 149 Fountain Pen"? Those have been in production since 1952 and don't look to be going anywhere.

I also note this shows a difference in semantics between our examples - Ruby and Python have opposite behaviour when it comes to failures in [] (KeyError for Python, nil for Ruby) and get/fetch (None for Python, KeyError in Ruby). I wonder if we want to encourage a particular style.

Freaky avatar Dec 07 '23 20:12 Freaky

Related to https://github.com/serpapi/public-roadmap/issues/1040.

ilyazub avatar Dec 08 '23 09:12 ilyazub

This seems to have been indirectly fixed with https://github.com/serpapi/SerpApi/pull/5824

The documentation has since been updated to use iPhone 14, which works:

require 'google_search_results' 

params = {
  q: "iphone 14",
  device: "desktop",
  api_key: "..."
}

search = GoogleSearch.new(params)
product_result = search.get_hash[:product_result]

btaunt avatar May 13 '25 15:05 btaunt