Flipkart Product Price Tracker using Python
Last Updated :
26 Apr, 2025
Flipkart Private Limited is an Indian e-commerce company. It sells many products and the prices of these products keep changing. Generally, during sales and festivals, the price of products drops, and our aim is to buy any product at the lowest possible price.
In this article, we will learn to build a Flipkart product price tracker using python to save money and buy products at the lowest possible price.
Approach
We will continuously check the price of our product using python and once the price hits our target price, we will inform the user.
As we are going to scrape prices from the webpage so we need to find an id or unique class to scrape the price. For this, we will go to the browser and open any product on Flipkart then right-click on price, then select inspect to get the required information.
We got two classes(_30jeq3, _16Jk6d), and we need to select the class that appears once on the whole webpage. For this, we will use python.
Libraries Required
Python libraries make it very easy for us to handle the data and perform typical and complex tasks with a single line of code.
- Requests - Requests library is of an integral part of Python for making HTTP requests to a specified URL.
- BeautifulSoup - It is a Python library for pulling data out of HTML and XML files.
- Time Module - As the name suggests Python time module allows one to work with time in Python.
Python3
import requests
product_url = "https://www.flipkart.com/lenovo-ideapad-3-core-i3-11th-gen\
-8-gb-512-gb-ssd-windows-11-home-82h801l7in-82h802fjin-\
82h802l3in-82h801lhin-thin-light-laptop/p/itm0e009f57a591b\
?pid=COMG9VHHG6Q3RRJX&lid=LSTCOMG9VHHG6Q3RRJXQHPK6Q&marketplace\
=FLIPKART&q=laptop&store=6bo%2Fb5g&srno=s_1_5&otracker=search\
&otracker1=search&fm=productRecommendation%2FattachForSwatchProducts\
&iid=66282f34-b708-4905-b834-af51e372d5c5.COMG9VHHG6Q3RRJX.SEARCH&ppt\
=pp&ppn=pp&ssid=q2pdky02pc0000001668894808794&qH=312f91285e048e09"
# fetch webpage
r = requests.get(product_url)
# get text of webpage
content = r.text
# class="_30jeq3 _16Jk6d"
print(f"Count of class _30jeq3 is {content.count('_30jeq3')}")
print(f"Count of class _16Jk6d is {content.count('_16Jk6d')}")
Output:
Count of class _30jeq3 is 4
Count of class _16Jk6d is 1
So, We will use class "_16Jk6d" to extract the price.
Complete code to track Flipkart product price tracker using Python
Define the URL of the product and target price. Define the check_price function that checks the price of the product and return price. Inside the check_price function, we use requests.get() to get the content of the webpage then we use BeautifulSoup to parse HTML. And then we use soup.find() to extract the price from the content of the webpage. Finally, we remove the Rs symbol and comma from it and convert it to an integer. We call the check_price() function and compare the current price with the target price again and again until the current price hits the target price. Once the current price hits the target price, we inform the user and exit the program.
Python3
import requests
from bs4 import BeautifulSoup
import time
product_url = "https://www.flipkart.com/lenovo-ideapad-3-core-i3-11th-gen\
-8-gb-512-gb-ssd-windows-11-home-82h801l7in-82h802fjin-\
82h802l3in-82h801lhin-thin-light-laptop/p/itm0e009f57a591b\
?pid=COMG9VHHG6Q3RRJX&lid=LSTCOMG9VHHG6Q3RRJXQHPK6Q&marketplace\
=FLIPKART&q=laptop&store=6bo%2Fb5g&srno=s_1_5&otracker=search\
&otracker1=search&fm=productRecommendation%2FattachForSwatchProducts\
&iid=66282f34-b708-4905-b834-af51e372d5c5.COMG9VHHG6Q3RRJX.SEARCH&ppt\
=pp&ppn=pp&ssid=q2pdky02pc0000001668894808794&qH=312f91285e048e09"
target_price = 35000
def check_price():
# fetch webpage
r = requests.get(product_url)
# parse the html
soup = BeautifulSoup(r.content, 'html5lib')
# extract price using class '_16Jk6d'
price = soup.find('div', attrs={"class": "_16Jk6d"}).text
# remove Rs symbol from price
price_without_Rs = price[1:]
# remove commas from price
price_without_comma = price_without_Rs.replace(",", "")
# convert price from string to int
int_price = int(price_without_comma)
return int_price
cur_price = check_price()
print(f"Current price is {cur_price}")
print("We will inform you, once price of product hits out target price")
print("Waiting...")
while True:
# get current price
cur_price = check_price()
if cur_price <= target_price:
print(f"Its time to buy product, its current price is {cur_price}")
break
# wait for 1 minute to check again
time.sleep(60)
Output:
Current price is 38799
We will inform you, once price of product hits out target price
Waiting...
Similar Reads
Build Fuel Price Tracker Using Python
In this modern-day lifestyle, fuel has become a necessity for all human beings. It is a base for our life-style. So, we are going to write a script to track their price using Python. Modules Needed bs4: Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module d
3 min read
Gps Tracker Using Python
A GPS tracker is a device designed to calculate precise and accurate locations generally by receiving data from satellite sources and computing the exact coordinates of the desired location. To achieve this, we will utilize the requests library in Python, along with some other necessary libraries. W
5 min read
Scraping Flipkart Data using Python
Web scraping is commonly used to gather information from a webpage. Using this technique, we are able to extract a large amount of data and then save it. We can use this data at many places later according to our needs. Â For Scraping data, we need to import a few modules. These modules did not come
3 min read
Stock Price Prediction Project using TensorFlow
Stock price prediction is a challenging task in the field of finance with applications ranging from personal investment strategies to algorithmic trading. In this article we will explore how to build a stock price prediction model using TensorFlow and Long Short-Term Memory (LSTM) networks a type of
5 min read
Get Bit Coin price in real time using Python
In this article we will see how we can get the current price of the bit coin. Bitcoin is a cryptocurrency. It is a decentralized digital currency without a central bank or single administrator that can be sent from user to user on the peer-to-peer bitcoin network without the need for intermediaries.
2 min read
GST Rate Finder GUI using Python-Tkinter
Prerequisites : Introduction to tkinter | Program to calculate GSTPython offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. In this article, we will learn how to create GST Rate Finder GUI application using T
3 min read
Personal Finance Tracker using Django
In this tutorial, we'll develop a Personal Finance Tracker using Django. We'll implement a robust login and logout system, and then proceed to establish CRUD (Create, Read, Update, Delete) operations for efficiently managing our expenses. The system will empower users to seamlessly delete or update
11 min read
Python - Dynamic GUI Calculator using Tkinter module
Python provides many options for developing GUI like Kivy, PyQT, WxPython, and several others. Tkinter is the one that is shipped inbuilt with python which makes it the most commonly used out of all. Tkinter is easy, fast, and powerful. Beginners can easily learn to create a simple calculator using
3 min read
Python | Pandas Series.product()
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.product() function returns th
3 min read
Amazon product availability checker using Python
As we know Python is a multi-purpose language and widely used for scripting. Its usage is not just limited to solve complex calculations but also to automate daily life task. Letâs say we want to track any Amazon product availability and grab the deal when the product availability changes and inform
3 min read