I wanted a phone last month, and its price kept changing. One day it was ₹18,999, two days later ₹17,499, then back up. Checking the page again and again got boring fast, so I wrote a small Python script to do it for me.
In this post, I’ll show you how to build the same thing. It will:

  • Read the product name and price from a Flipkart page
  • Save every price in a small database
  • Send you an email when the price drops below your target

You only need basic Python.

Before you start

Two things to know first.

  • Flipkart does not like bots: If you send too many requests, you will get blocked or see a captcha page. So keep it small: a few products, a few checks per day.
  • Page structure changes: Flipkart changes its HTML now and then, so a class name that works today may break next month. I’ll show a safer way to read the price, but you should still expect to fix things sometimes.

Also, read Flipkart’s terms of use. Use this for personal tracking, not for copying their data at scale.

Setup

pip install requests beautifulsoup4 

SQLite and smtplib come with Python, so there is nothing else to install.

Project layout:

price-tracker/ ├── tracker.py ├── products.json └── prices.db (created automatically) 

Put the products you want to watch in products.json:

[ { "name": "My phone", "url": "https://www.flipkart.com/your-product-url", "target_price": 17000 } ] 

Step 1: Fetch the page

Flipkart often rejects requests that have no browser headers. So we add a User-Agent.

import requests HEADERS = { "User-Agent": ( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/124.0 Safari/537.36" ), "Accept-Language": "en-IN,en;q=0.9", } def get_html(url): resp = requests.get(url, headers=HEADERS, timeout=15) resp.raise_for_status() return resp.text 

If you get a 403 or 429 here, you are being blocked. Slow down, wait a while, and try again.

Step 2: Get the price

There are two ways to do it.

  • Way 1: JSON-LD data (more stable): Many product pages include a small block of structured data for search engines. Its format changes less often than CSS class names.
  • Way 2: CSS class (fallback): Flipkart’s class names look random (like Nx9bqj) and change from time to time. Treat them as temporary.
import json import re from bs4 import BeautifulSoup def clean_price(text): digits = re.sub(r"[^\d.]", "", text) return float(digits) if digits else None def parse_product(html): soup = BeautifulSoup(html, "html.parser") title, price = None, None # Way 1: JSON-LD for tag in soup.find_all("script", type="application/ld+json"): try: data = json.loads(tag.string or "") except json.JSONDecodeError: continue items = data if isinstance(data, list) else [data] for item in items: if item.get("@type") == "Product": title = item.get("name") offers = item.get("offers", {}) if isinstance(offers, list) and offers: offers = offers[0] price = clean_price(str(offers.get("price", ""))) if price: return title, price # Way 2: fallback to class names (check these in DevTools) title_tag = soup.select_one("span.VU-ZEz") or soup.find("h1") price_tag = soup.select_one("div.Nx9bqj") if title_tag: title = title_tag.get_text(strip=True) if price_tag: price = clean_price(price_tag.get_text()) return title, price 

If the fallback returns None, open the product page in Chrome, right-click the price, choose Inspect, and copy the current class name into select_one(...).

Step 3: Save prices in SQLite

A tracker is only useful if it remembers old prices. SQLite is perfect for this: it’s just one file.

import sqlite3 from datetime import datetime def init_db(): conn = sqlite3.connect("prices.db") conn.execute(""" CREATE TABLE IF NOT EXISTS prices ( id INTEGER PRIMARY KEY AUTOINCREMENT, url TEXT, title TEXT, price REAL, checked_at TEXT ) """) return conn def save_price(conn, url, title, price): conn.execute( "INSERT INTO prices (url, title, price, checked_at) VALUES (?, ?, ?, ?)", (url, title, price, datetime.now().isoformat(timespec="seconds")), ) conn.commit() def last_price(conn, url): row = conn.execute( "SELECT price FROM prices WHERE url = ? ORDER BY id DESC LIMIT 1", (url,), ).fetchone() return row[0] if row else None 

Step 4: Send the price-drop alert

I’m using Gmail here. Do not use your normal password. Turn on 2-step verification in your Google account and create an App Password. Put it in an environment variable, never in your code.

import os import smtplib from email.message import EmailMessage def send_email(subject, body): msg = EmailMessage() msg["From"] = os.environ["ALERT_EMAIL"] msg["To"] = os.environ["ALERT_EMAIL"] msg["Subject"] = subject msg.set_content(body) with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server: server.login(os.environ["ALERT_EMAIL"], os.environ["ALERT_APP_PASSWORD"]) server.send_message(msg) 

Set them in your terminal:

export ALERT_EMAIL="you@gmail.com" export ALERT_APP_PASSWORD="your-16-letter-app-password" 

(On Windows PowerShell, use $env:ALERT_EMAIL="you@gmail.com".)

Step 5: Put it all together

import json import time import random def check_all(): conn = init_db() with open("products.json") as f: products = json.load(f) for p in products: try: html = get_html(p["url"]) title, price = parse_product(html) except Exception as e: print(f"Could not check {p['name']}: {e}") continue if price is None: print(f"Price not found for {p['name']}. Selectors may have changed.") continue previous = last_price(conn, p["url"]) save_price(conn, p["url"], title or p["name"], price) print(f"{title}: ₹{price:,.0f}") below_target = price <= p["target_price"] dropped = previous is not None and price < previous if below_target and dropped: send_email( f"Price drop: {title}", f"Now ₹{price:,.0f} (was ₹{previous:,.0f}).\n" f"Your target: ₹{p['target_price']:,}\n\n{p['url']}", ) print("Alert sent!") time.sleep(random.uniform(5, 12)) # be gentle if __name__ == "__main__": check_all() 

Notice the alert only fires when the price is below your target and it just dropped. Without the second check, you would get the same email on every run while the price stays low.

Step 6: Run it automatically

Linux / macOS (cron): Check every 6 hours.

0 */6 * * * cd /path/to/price-tracker && /usr/bin/python3 tracker.py 

Windows: Use Task Scheduler and point it to python tracker.py.

No always-on machine?

A free GitHub Actions workflow with a schedule can run it for you. Just keep in mind that SQLite files won’t persist between runs there, so you’d need to commit the DB back or use another store.

Common problems

Problem Likely reason Fix
403 or 429 error Too many requests or missing headers Add delays and reduce request frequency
Price is None Class name changed or page is showing a CAPTCHA Inspect the page and update the selector
Wrong price (like EMI amount) Selector matched another element Prefer the JSON-LD method
Email not sending Using the normal Gmail password Use an App Password

Ideas to extend it

  • Send alerts on Telegram instead of email
  • Draw a price history chart with matplotlib
  • Track the same product on Amazon too and compare
  • Add a “lowest price ever” alert

Frequently Asked Questions

1. Is it legal to scrape Flipkart?

It depends on the site’s terms and how you use the data. Checking a few products for yourself is very different from collecting lakhs of listings. Read Flipkart’s terms, keep your request rate low, and don’t resell the data. If you plan to build a business on it, talk to a lawyer.

2. Why does my script return no price even though the page opens fine in my browser?

Most of the time, either the HTML class names changed, or Flipkart showed your script a captcha or block page instead of the product. Print the first 500 characters of html to check. If you see a captcha, wait and slow down. If the page looks normal, re-inspect the price element and update your selector.

3. Do I need Selenium or Playwright?

Not for most product pages, since the price is usually already in the HTML. If you later see pages where the price loads only after JavaScript runs, a browser tool like Playwright will help. It’s slower and heavier, so use requests first.

4. How often should I check the price?

Every few hours is enough for personal use. Prices rarely change every minute, and frequent requests raise your chance of getting blocked. Add random delays between products too.

5. Can I get alerts on WhatsApp or Telegram instead of email?

Yes. Telegram is the easiest: create a bot with BotFather, get your chat ID, and send a simple requests.post to the Telegram Bot API instead of calling send_email. WhatsApp needs the paid Business API or third-party services, so Telegram is better for a hobby project.

Wrapping up

That’s the full tracker: fetch the page, read the price, save it, and email yourself when it drops. It’s around 100 lines, and it has already saved me a few hundred rupees.

If you build on it, I’d love to see what you add. Tell me in the comments, and if Flipkart changes its HTML and something breaks, drop the error there, and we can fix it together.

Need price tracking for your business?

A script like this works well for personal use. But once you need to track hundreds or thousands of products across Flipkart, Amazon, Walmart, Target, Best Buy, eBay, Canadian Tire, AliExpress, Temu, Shopee, Etsy, and other marketplaces, a hobby script will not keep up. You will run into blocks, changing page layouts, and data that needs cleaning before anyone can use it.

That is where MaaTech Analytics can help. We build business-ready data solutions, including:

  • Competitor price monitoring: Track prices, discounts, and stock across e-commerce platforms on a schedule
  • Custom web scraping pipelines: Reliable, maintained scrapers that handle blocks, layout changes, and scale
  • Clean, structured data delivery: CSV, Excel, API, or database feeds that plug into your existing tools
  • Dashboards and alerts: Price history, trend charts, and instant notifications when something changes

Explore our eCommerce data scraping services to see how we can help, or contact us and tell us what you need to track.