Using Google Custom Search on Google Shopping
Asked Answered
G

2

7

I would like to make an API call to retrieve Google Shopping result (basically the price of the product) I logged in to Google Custom Search, created a new Search engine called General, and chose in websites: http://www.google.com/shopping.

However, when I try to search, I get only 1 result and without the price.

How can I retrieve Google Shopping results including the item price? Is there another way rather than scrapping the page? (which I believe it totally not recommended)

Guib answered 12/2, 2015 at 19:4 Comment(1)
Did you ever find a solution to this? ThanksIseabal
A
3

You can get all the product details from Google Content API for shopping, including the price of the product. Below is a code snippet to retrieve details of a single product:

  /**
* Retrieves the product with the specified product ID from the Content API for Shopping
Server.
*
* @param productId The ID of the product to be retrieved.
* @return The requested product.
* @throws HttpResponseException if the retrieval was not successful.
* @throws IOException if anything went wrong during the retrieval.
*/

private Product getProduct(String productId)
  throws IOException, HttpResponseException {
    // URL
    String url = rootUrl + userId + "/items/products/schema/" + productId;

    // HTTP request
    HttpRequest request = requestFactory.buildGetRequest(new GoogleUrl(url));

    // execute and interpret result
    return request.execute().parseAs(Product.class);
}

You need to write a Product model class for the above code. The class looks like:

/**
* Class for representing a product entry.
*/
public class Product extends BatchableEntry {
    @Key("sc:additional_image_link")
    public List<String> additionalImageLinks;
    ...
    @Key("scp:price")
    public Price price;
    ...
    @Key("scp:product_type")
    public String productType;

    @Key("scp:quantity")
    public Integer quantity;
    ...
    ...
}

You can download the whole source code and get the explanation of the code from this example provided by Google Developers.

Arlaarlan answered 19/2, 2015 at 20:8 Comment(5)
wouldn't it return to me only MY products?Guib
Yes it will return your account's products only.Arlaarlan
I look for a solution that will return ALL products. not mine - as I don't haveGuib
That is hard to get unfortunately.Arlaarlan
well. this is what I was looking forGuib
V
0

Seams Google Custom Search not support Google Shopping.

But here is a third party API(not official API):

https://serpapi.com/shopping-results

Price:

https://serpapi.com/#pricing

Volcanic answered 2/7, 2020 at 1:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.