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)
From the Programmable Search Engine homepage, click Create a custom search engine or New search engine. In the Sites to search box, type one or more sites you want to include in the search results. You can include any sites on the web, even sites you don't own. Don't worry, you can always add more later.
With Google Cloud Operations you can create custom dashboards, set up alerts, and access metrics data programmatically. To access Custom Search JSON API usage data in Google Cloud Operations, select "Resource type: Consumed API" and filter on "service = 'customsearch.googleapis.com'" in the Query Builder.
Google Web Search API has been deprecated and replaced with Custom Search API (see http://code.google.com/apis/websearch/).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With