Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Flipkart Product Price Tracker using Python
Next article icon

Flipkart Product Price Tracker using Python

Last Updated : 28 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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...

Next Article
Flipkart Product Price Tracker using Python
author
06akshay2002
Improve
Article Tags :
  • Technical Scripter
  • Python
  • Technical Scripter 2022
Practice Tags :
  • python

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
    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
    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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences