Obtain google shopping matches

225 Views Asked by At

So, as the title says, I would like to emulate the behaviour of the google shopping tab.

For example, whenever I search for "Samsung A50" I get different shopping results from different merchants.

Is there a way in the whole google shopping API to do so?

2

There are 2 best solutions below

1
On BEST ANSWER

The content API is for submitting data to Google Merchant Center.

Currently, there is no official Google API for returning results of shopping ads. You may want to use a tool such as semrush.

0
On

For scraping Google Shopping you can use third party API like Google Shopping API from SerpApi (paid API with a free plan that handles blocks and parsing on their backend).

Check code in the online IDE.

from serpapi import GoogleSearch
import json

params = { 
  "engine": "google_shopping",                  # search engine. Google, Bing, Yahoo, Naver, Baidu...
  "q": "Samsung A50",                           # query
  "location": "Austin, Texas, United States",   # where you want the search to originate
  "hl": "en",                                   # language
  "gl": "us",                                   # country of the search, US -> USA
  "api_key": "..."                              # serpapi key, https://serpapi.com/manage-api-key
}

all_titles = []

search = GoogleSearch(params)                   # where data extraction happens on the backend
results = search.get_dict()                     # JSON -> Python dict

for result in results["inline_shopping_results"]:
    all_titles.append({"title": result.get("title")})

print(json.dumps(all_titles, indent=2))

Example output:

[
  {
    "title": "Samsung Galaxy A50 US Version Factory Unlocked Cell Phone with 64GB Memory, 6.4\" Screen, Black, [SM-A505UZKNXAA]"
  },
  {
    "title": "Galaxy A50 64GB Black Unlocked GSM"
  },
  {
    "title": "Samsung Samsung Galaxy A53 5G - Amazing Black - 128GB (with 24 monthly payments) - Samsung Galaxy Phone"
  },
  {
    "title": "Samsung Galaxy A23 5G - Black - 64GB (with 24 monthly payments) - Samsung Galaxy Phone"
  },
  other results ...
]

There's a Google Shopping playground if you want to see what else can be extracted using API.

Disclaimer, I work for SerpApi.