Skip to content

ompatel100/price-tracker

Repository files navigation

Personal Price Tracker (Amazon and Flipkart)

A personal e-commerce price tracker for Amazon and Flipkart, allowing you to track product prices, view historical trends, receive alerts when prices drop. Built with Python, Selenium, SQLite, Streamlit, and Telegram notifications.


Features

  • Track Products: Add products from Amazon and Flipkart with target prices.
  • Dashboard: View all tracked products with latest price, target, and status.
  • Price History: Visualize historical price trends with interactive charts.
  • Real-time Alerts: Get Telegram notifications for price drops or when target prices are reached.
  • Scraping: Runs daily by scheduling.

Architecture & Workflow

  1. Database

    • Uses SQLite (price_tracker.db) to store all product and pricing data.
    • Products table holds: product name, URL, source (Amazon/Flipkart), and target price.
    • PriceHistory table tracks historical prices for each product.
  2. Scraping

    • Amazon: Handled by scraper_amazon.py.
    • Flipkart: Handled by scraper_flipkart.py.
    • Both use Selenium with undetected_chromedriver to mimic human browsing and bypass bot detection on these e-commerce sites.
    • scraper_runner.py coordinates scraping for all products, updates the database, and triggers Telegram alerts when necessary.
  3. Notifications

    • telegram_notify.py sends real-time messages via the Telegram Bot API whenever a price drops or a target price is reached.
  4. Dashboard

    • streamlit_app.py provides an interactive web interface to:

      • Add or remove products
      • View all tracked products with current prices and status
      • Explore historical price trends via interactive charts
      • Run the scraper manually if needed

Tech Stack

  • Python 3.11+ – For all scripts and dashboard.
  • Selenium + undetected_chromedriver – Robust scraping with bot detection bypass.
  • SQLite – Lightweight, easy-to-use database for products and price history.
  • Streamlit – Quick and interactive dashboard interface.
  • Plotly – Dynamic charts for visualizing price trends.
  • Telegram Bot API – Real-time notifications for price changes and targets.

Setup

  1. Clone the repository
git clone https://github.com/yourusername/price-tracker.git
cd price-tracker
  1. Create a Virtual Environment (optional):

    python -m venv venv
  2. Activate the Virtual Environment:

    • On Windows:

      .\venv\Scripts\activate
    • On macOS/Linux:

      source venv/bin/activate
  3. Install dependencies

pip install -r requirements.txt

Requirements include: selenium, undetected-chromedriver, pandas, plotly, streamlit, requests

  1. Create database
python create_db.py
  1. Run Streamlit dashboard
streamlit run streamlit_app.py

Telegram Bot Notifications

This project uses a Telegram bot to send real-time alerts when:

  • A tracked product’s price drops compared to the previous check.
  • A product reaches or goes below your target price.

Steps to Set Up

  1. Create a Telegram Bot

    • Open Telegram and go to BotFather or search for BotFather
    • Start a chat and use /newbot to create a new bot.
    • Note down the bot token provided.
  2. Get Your Chat ID

    • Start a chat with your bot or use an existing group.
    • Send any message to the bot.
    • Use https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates in your browser to retrieve the chat ID from the JSON response.
  3. Update constants.py

    BOT_TOKEN = "<YOUR_TELEGRAM_BOT_TOKEN>"
    CHAT_ID = "<YOUR_CHAT_ID>"

Scheduling

You can automate price tracking by scheduling the scraper to run at specific times. If you are using a Python virtual environment, ensure the scheduler uses the environment's Python interpreter so all dependencies are available.

Windows (Task Scheduler):

  1. Open Task SchedulerCreate Task.
  2. Set Trigger: Daily at 7:30 PM.
  3. Set Action → Start a program:
Program/script: C:\path\to\venv\Scripts\python.exe
Add arguments: C:\path\to\price_tracker\scraper_runner.py
  1. Save and test the task.

Linux/macOS (Cron Job):

Run the scraper daily at 7:30 PM:

30 19 * * * /path/to/your/venv/bin/python /path/to/price_tracker/scraper_runner.py
  • Replace /path/to/your/venv with your virtual environment path.
  • Replace /path/to/price_tracker with the project directory.

Alternative (using a shell script):

#!/bin/bash
source /path/to/your/venv/bin/activate
python /path/to/price_tracker/scraper_runner.py

Make it executable:

chmod +x run_scraper.sh

Add to cron:

30 19 * * * /path/to/price_tracker/run_scraper.sh

Usage

Once the dashboard is running, you can easily manage and track products:

  • Dashboard: View all tracked products with current price, target price, and status.
  • Add Product: Add a new product by entering its name, URL, source (Amazon/Flipkart), and target price.
  • Price History: Explore historical price trends with interactive charts to see how prices have fluctuated over time.
  • Manual Scraper Run: Trigger the scraper manually from the dashboard to update prices immediately.
  • Alerts: Receive real-time Telegram notifications when a price drops or a target is reached, keeping you informed even when you’re away from the dashboard.

Screenshots

Dashboard

Dashboard

Dashboard


Add Product

Add Product


Price History

Price History


Telegram Alert

Telegram Alert

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages