Flipkart Product Price Tracker using Python

Flipkart, one of India's biggest online retailers, offers a variety of products at competitive costs. However, manually monitoring pricing can be challenging due to Flipkart's rapid price fluctuations. This tutorial will teach you how to build a Python Flipkart product price tracker to monitor price changes automatically.

Required Libraries

To build a Flipkart product price tracker using Python, we need to install the following modules ?

  • requests ? to fetch the webpage of the product

  • BeautifulSoup ? to parse the HTML content and extract product information

  • re ? to extract numerical values from price strings

  • time ? to add delays between requests

Install the required modules using pip ?

pip install requests
pip install beautifulsoup4

Algorithm

Here are the steps to build a Flipkart product price tracker ?

  • Import necessary modules ? Import requests, re, time, and BeautifulSoup modules

  • Fetch the webpage ? Get the product page from Flipkart using requests

  • Parse the webpage ? Use BeautifulSoup to parse the HTML content

  • Extract product information ? Get product name and price using BeautifulSoup's find() method

  • Check the price ? Compare current price with target price and trigger notification

  • Add delay ? Wait before checking again to avoid overwhelming the server

Implementation

Here's a complete price tracker implementation ?

import requests
import re
import time
from bs4 import BeautifulSoup as bs

def check_fk_price(url, target_amount):
    try:
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        }
        request = requests.get(url, headers=headers)
        soup = bs(request.content, 'html.parser')

        # Extract product name
        product_name = soup.find("span", {"class": "B_NuCI"}).get_text()
        
        # Extract price
        price_element = soup.find("div", {"class": "_30jeq3 _16Jk6d"})
        price = price_element.get_text()
        
        # Extract numerical value from price
        price_int = int(''.join(re.findall(r'\d+', price)))
        
        print(f"{product_name} is at {price}")
        
        if price_int < target_amount:
            print("? Price Drop Alert! Book Quickly!")
        else:
            print("? Still waiting for better price...")
            
    except Exception as e:
        print(f"Error fetching price: {e}")

# Sample URL (replace with actual product URL)
URL = "https://www.flipkart.com/apple-macbook-air-m1-8-gb-256-gb-ssd-mac-os-big-sur-mgn93hn-a/p/itmb53580bb51a7e"

# Check price every hour
while True:
    check_fk_price(URL, 90000)
    print("Sleeping for 1 hour...")
    time.sleep(3600)  # 1 hour delay

Output

APPLE 2020 Macbook Air M1 - (8 GB/256 GB SSD/Mac OS Big Sur) MGN93HN/A (13.3 inch, Silver, 1.29 kg) is at ?84,490
? Price Drop Alert! Book Quickly!
Sleeping for 1 hour...

Running in Background

To run the script continuously in the background on Windows, create a batch file ?

Steps to Create Background Runner

  • Open Notepad and paste the following content ?

@echo off
"C:\Program Files\Python310\python.exe" "C:\price-tracker.py"
pause
  • Save as price-tracker.bat (ensure .bat extension)

  • Update the Python path according to your system installation

  • Double-click the .bat file to run the tracker

Enhanced Features

You can enhance the price tracker with additional features ?

  • Email notifications ? Send email alerts when price drops

  • Multiple products ? Track prices for multiple products simultaneously

  • Price history ? Store historical price data in a file or database

  • Percentage-based alerts ? Trigger alerts based on percentage price drops

Important Notes

  • Always include proper headers in requests to avoid being blocked

  • Add reasonable delays between requests (minimum 1 hour recommended)

  • HTML structure may change, requiring updates to CSS selectors

  • Respect website terms of service and rate limits

Conclusion

This Python-based Flipkart price tracker automatically monitors product prices and alerts you when they drop below your target amount. The tracker runs continuously in the background, helping you save money by catching the best deals without manual monitoring.

Updated on: 2026-03-27T13:08:40+05:30

554 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements