A personal deal-monitoring tool built for snappshop.ir during Black Friday 2024. It scrapes product listing pages with Selenium and undetected-chromedriver to reduce bot detection, filters for high-value discounts, stores results in a local database, and surfaces the best deals through a Django admin dashboard with auto-refresh and audio alerts.
- Automated price scanning — scrolls category pages and extracts product name, URL, original price, sale price, and discount percentage
- Bot-detection bypass — uses
undetected-chromedriverinstead of stock Selenium Chrome to avoid common robot checks on snappshop.ir - Deal filtering — keeps only products above configurable discount and savings thresholds (defaults: ≥ 20% off and ≥ 2,500,000 IRR saved)
- Django admin dashboard — browse all products or a filtered "non-junk" view with live updates
- Audio alerts — beeps when qualifying deals appear in the non-junk view
- Desktop launcher — CustomTkinter GUI to start the admin server and background scan loop
- Checkout automation — optional Selenium helpers to add items to basket and proceed through checkout
GUI / management command
│
▼
scan_products() ← apps/product/tasks.py
│
▼
Selenium driver ← apps/product/automation/ (undetected-chromedriver)
│
▼
SQLite database ← Product / ProductCategory models
│
▼
Django admin ← auto-refreshing changelist + sound alert
On each scan, products found in a category are upserted by URL. Products that no longer appear on the listing are marked inactive (not deleted), preserving history and manual flags.
- Python 3.12+
- Google Chrome (matching the ChromeDriver version in
.env) - undetected-chromedriver — installed via
requirements.txt; patches ChromeDriver to bypass typical automation fingerprints - A Chrome user profile with an active snappshop.ir login session
# Clone and enter the project
cd snappshop
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your SECRET_KEY, Chrome paths, and profile location
# Apply database migrations
python manage.py migrate
# Create an admin user
python manage.py createsuperuserAll settings are loaded from .env via python-decouple. See .env.example for the full list.
| Variable | Description |
|---|---|
SELENIUM_DRIVER_BINARY_LOCATION |
Path to the Chrome binary |
SELENIUM_DRIVER_PROFILE_LOCATION |
Chrome user-data directory (reuses login session) |
SELENIUM_DRIVER_PROFILE |
Profile name within the user-data directory (usually Default) |
SELENIUM_REQUIRE_LOGIN_CONFIRMATION |
Pause for manual login on first run (True / False) |
DEAL_MIN_OFF_PERCENT |
Minimum discount percentage to keep a product |
DEAL_MIN_SAVINGS |
Minimum savings in IRR to keep a product |
SCAN_INTERVAL_SECONDS |
Delay between scan cycles in the GUI |
python scripts/gui.py- Click Start Admin Panel — opens the Django server at
http://localhost:8000/admin/ - Click Start Scan — begins polling active product categories in the background
- Open the Non-junk products view in admin to watch deals with audio alerts
- Click Stop Scan or Exit when done
On the first scan, Chrome opens and waits for you to log in to snappshop.ir (unless SELENIUM_REQUIRE_LOGIN_CONFIRMATION=False and the profile is already authenticated).
python manage.py scan_productsUseful for one-off scans or scheduling via cron/systemd without the GUI.
Add product categories under Products categories in admin. Each category needs a snappshop.ir listing URL and is_active checked. The scanner visits every active category on each run.
- Products — full list of scanned products
- Non-junk products — filtered view (
is_junk=False) with auto-refresh every 5 seconds and sound alerts
Mark uninteresting deals as junk in admin to hide them from the alert view.
snappshop/
├── apps/
│ ├── base/ # Shared BaseModel and driver bootstrap
│ └── product/
│ ├── automation/ # Selenium driver, scanner, checkout helpers
│ ├── management/ # scan_products management command
│ ├── models.py # ProductCategory, Product, NonJunkProduct
│ ├── tasks.py # Scan orchestration and DB upsert logic
│ └── templates/ # Auto-refreshing admin changelist
├── scripts/
│ └── gui.py # Desktop launcher
├── snappshop/ # Django project settings
├── .env.example
└── manage.py
snappshop.ir uses CSS-module class names with content hashes (e.g. PLPSection_plp-products-container__HSjLH). These change when the frontend is redeployed. When scraping breaks, update the constants in apps/product/automation/selectors.py.
This tool was built for personal use during a specific sale event. It automates a third-party website without an official API. Use responsibly, respect the site's terms of service, and be aware that selectors and page structure can change at any time.