Python Tutorial 47: Product Price Trackers of Google Shopping, Walmart, HomeDepot Product Using SERP API

In this Python Tutorial, I would talk about how to create price trackers for three popular retail marketplaces or channels from an eCommerce seller perspective. In this tutorial, we would use some modules listed as below and by the end of it, you can use a tracker built by yourself. Refreshing a dashboard every morning can become part of your lifestyle that relieves your busy work.

price tracker

In this Python Tutorial, I would talk about how to create price trackers for three popular retail marketplaces or channels from an eCommerce seller perspective. In this tutorial, we would use some modules listed below and by the end of it, you can use a tracker built by yourself. Refreshing a dashboard every morning can become part of your lifestyle that relieves your busy work.

Python Modules: SERP API, selenium, BeautifulSoup, Pandas

What is SERP API

SERP APIs allow you to analyze, review, track and improve your website’s visibility on the diversity of search engines worldwide. They are such as Google, Baidu, Yahoo, Walmart, eBay, etc.

Creating an account using the SERP API is easy, as the platform offers a free API with limited monthly call quotas. Once you sign up for the account, you can get the API key from your account, and the key allows you to make requests through the API.

Based on the endpoint request, the SERP APIs allow you to extract information from SERP such as organic results, paid results, and competitor product information. The APIs allow clients to optimize their content, identify and fix website problems, and simplify the data collection process.

Whatsmyserp, SerpHouse, Apify, DataForSeo, Zernserp, and Serpstack are examples of free SERP APIs.

Scrape Product IDs

One of the most useful tips and tricks from my using experiences is to scrape the target product ID first before using the free API. It’s because generally, the API has a limited quota for you to call every month. For saving costs, we could only use the API to refresh the target product price rather than waste the quotas in scraping the product ID. And as you might be aware, basically free APIs can offer a free quota to scrape product information using product id.

Take HomeDepot for example. We could code a SERP scraping first using selenium and your target product keywords. Below is an example we scrape the security camera google nest in the smart home category. You can refer to the home depot search URL parameter structure to code

url = driver.get('https://www.homedepot.com/b/' + category + '/N-5yc1vZc1jw/Ntk-EnrichedProductInfo/Ntt-' + query + '?sortorder=desc&sortby=topsellers')

soup = BeautifulSoup(driver.page_source, 'html.parser')

result = soup.find_all('div', {'class': 'browse-search__pod col__true-12 col__6-12--xs col__4-12--sm col__3-12--md col__3-12--lg'})

…….

​​homedepotSERP('Smart-Home', 'google nest camera')

price tracker

From this script, we can scrape the product title, price, and ID from the SERP. The ID can be used the moment you set up the automatic price tracker in the other script.

Google Shopping Price Tracker

SERP API provides rich parameters for developers to filter the Google Shopping product information, such as by country, and by language. You can also add the no_cache parameter to get the latest information and enhance the accuracy of the price tracker

from serpapi import GoogleSearch 

params = { 

"engine": "google_product", 

"product_id": "4172129135583325756", 

"gl": "us", 

"hl": "en", 

"api_key": "cf16ea6ebf32764c3c13fae81d14425734dbc6ac776878c373ab80d7fba43bb9" } 

search = GoogleSearch(params) results = search.get_dict() 

product_results = results['product_results']

price tracker

From the product ID, you can grab the product title, original price, current price, rating, reviews, etc.

Walmart Price Tracker

Similar to Google Shopping product API, you can add the engine parameter value, no_cache, and product ID data you are going to fetch, it’s super straightforward and the data response is fast.

params = {

"engine": 'walmart_product',

"product_id": '808410926',

"api_key": apiKEY,

"no_cache": 'true'

}

search = GoogleSearch(params)

results = search.get_dict()

shopping_results = results['product_result']

price tracker

Home Depot Price Tracker

Same to the Walmart price tracker, you just need to replace the engine name value and product ID, you can grab the data. The data type from SERP API is a dictionary format. It’s super convenient to select the product information you need. However, the accessible data options are slightly different from Walmart. Please go to SERP API documentation to double-check, you can’t just copy and paste the Walmart code used to Home Depot.

params = {

"engine": 'home_depot_product',

"product_id": productID,

"api_key": apiKEY,

"no_cache": 'true'

}

search = GoogleSearch(params)

results = search.get_dict()

shopping_results = results['product_results']

Full Python Script of Product Price Trackers of Google Shopping, Walmart, Homedepot Using SERP API

If you are interested in the full Python script of Product Price Trackers of Google Shopping, Walmart, Homedepot Product SERP API, please subscribe to our newsletter by adding the message “Python Tutorial 42”. We would send you the script immediately to your mailbox.

Contact us

I hope you enjoy reading Python Tutorial 47 – Product Price Trackers of Google Shopping, Walmart, Homedepot Product SERP API. If you did, please support us by doing one of the things listed below, because it always helps out our channel.

  • Support my channel through PayPal (paypal.me/Easy2digital)
  • Subscribe to my channel and turn on the notification bell Easy2Digital Youtube channel.
  • Follow and like my page Easy2Digital Facebook page
  • Share the article to your social network with the hashtag #easy2digital
  • Buy products with Easy2Digital 10% OFF Discount code (Easy2DigitalNewBuyers2021)
  • You sign up for our weekly newsletter to receive Easy2Digital latest articles, videos, and discount codes on Buyfromlo products and digital software
  • Subscribe to our monthly membership through Patreon to enjoy exclusive benefits (www.patreon.com/louisludigital)