Stage 5 track

Track: Automation

Capstone: Daily price tracker · Tools: requests, BeautifulSoup, Playwright, openpyxl · Time: ~2 weeks (one step every 2–3 days, ~3 hours a day)

Who this track is for

You like the idea of writing a script once and having it do boring, repetitive work for you forever after — checking a website, filling a spreadsheet, clicking through a form. You were comfortable with urllib/HTTP basics and regex in Stage 1–2.

Job roles this maps to: QA Automation Engineer, SDET (Software Development Engineer in Test), RPA (Robotic Process Automation) Developer, and general "automation/scripting" responsibilities inside almost any software or operations team.

You already have, from earlier stages:

  • Strings and regex basics (Parts 2, 8)
  • Files, CSV and JSON (Part 8)
  • HTTP basics: methods, status codes, headers (Part 12)
  • SQL and sqlite3, for storing results over time (Part 12)

What you'll learn, step by step

Step 1 — requests

Builds on: Part 12 (HTTP methods, status codes, headers, JSON).

  • requests is the most widely used third-party HTTP client for Python — the same GET/POST/headers/JSON ideas from Part 12, with a friendlier interface than the standard library's urllib.
  • Sessions (reusing cookies/headers across multiple calls), timeouts, and checking response.status_code before trusting a response.
  • Being a good citizen: respect a site's rate limits, add a delay between requests, and always check a site's terms of use / robots.txt before scraping it.
  • See the library's own official documentation for exact method signatures — it isn't on the canonical-domain list this course sticks to, so search "requests library python documentation" and use the official project docs you land on, not a blog post.

Step 2 — BeautifulSoup

Builds on: Step 1 (requests gets you the HTML), Part 8 (regex — but HTML parsing is why you don't want to use regex for this).

  • Parsing HTML into a tree you can search, instead of treating a page as one long string.
  • Finding elements by tag, class or id, and reading their text or attributes.
  • This works for static pages: pages where the content you want is already in the HTML requests downloaded, before any JavaScript runs.

Step 3 — Playwright

Builds on: Step 2 (you'll notice some pages don't give you the data with just requests + BeautifulSoup).

  • Many modern sites load their content with JavaScript after the page loads — requests only sees the empty shell. Playwright drives a real browser, so JavaScript runs and the content actually appears.
  • Launching a browser, navigating to a page, locating elements, clicking, filling in forms, and waiting for content to appear (never add an arbitrary fixed sleep — wait for the actual element or condition).
  • Use Playwright when requests + BeautifulSoup isn't enough; don't reach for a full browser by default, since it's slower and heavier.

Step 4 — openpyxl

Builds on: Part 8 (CSV — openpyxl is the .xlsx equivalent, with more formatting power).

  • Reading and writing real Excel .xlsx files (not just CSV): cells, rows, columns, sheets.
  • Basic formatting: bold headers, column widths, number formats — the difference between a dumped table and a report someone will actually open.
  • Writing a chart into the workbook is a bonus; a clean, well-labelled table is the priority.

Step 5 — Put it together

Builds on: everything above, plus Part 12's sqlite3 for storing history.

  • Combine scraping (requests/BeautifulSoup, or Playwright where needed) with storage (SQLite) and reporting (openpyxl) into one daily-run script.

Step 6 — Polish (optional buffer)

Scheduling, logging, error handling, README, stretch goal.

Setup pointers (official docs only)

(requests has no link here — see the note in Step 1. Find its official project documentation yourself and verify it's the real project before trusting any install instructions.)

Install everything inside a virtual environment, as in Part 7. Playwright also needs a one-time step to download browser binaries after pip install — its official docs cover the exact command for your OS.

Capstone brief: Daily price tracker

User stories

  • As a shopper, I want to track the price of a few products I care about over time.
  • As a shopper, I want to run the tracker once a day and have it remember yesterday's prices, so I can see what changed.
  • As a shopper, I want an Excel report showing current prices and whether each one went up, down, or stayed the same.
  • As a shopper, I want to be told clearly (in the report, or a log message) when a product's price dropped, so I don't have to read every row myself.
  • As a developer, I want the scraping logic (how to read a price) kept separate from the storage logic (how to remember it) and the reporting logic (how to present it), so a site's page layout changing only breaks one part of the code.

Architecture sketch

  list of products to track (name + URL)
        │
        ▼
┌───────────────────────────┐
│ fetchers/                   │  requests + BeautifulSoup for static pages,
│                             │  Playwright for pages that need JavaScript
└────────────┬──────────────┘
             │  (today's price per product)
             ▼
┌───────────────────────────┐
│ storage                     │  SQLite: one row per (product, date, price)
│                             │  — append-only history, like a ledger
└────────────┬──────────────┘
             │  (today's and yesterday's prices)
             ▼
┌───────────────────────────┐
│ report                      │  openpyxl: one sheet, current price,
│                             │  change vs. yesterday, highlight drops
└────────────┬──────────────┘
             ▼
     daily_report.xlsx

Keep one small "fetcher" function per site/page shape (a page's HTML structure is specific to that site), but one shared storage layer and one shared report builder — the same "only one layer knows the messy details" idea from the library manager's Repository class.

Milestones

  1. One product, one fetch — given one product URL, fetch and print today's price.
  2. History — save that price into a SQLite table with the date; running it twice on the same day either updates or skips (your choice, documented).
  3. Multiple products — track a small list (3–5 products) instead of just one.
  4. Comparison — for each product, compute the change vs. the most recent earlier price in the database.
  5. Report — write an .xlsx report: product, current price, previous price, change, with headers formatted and price drops visually highlighted.
  6. One command, one run — a single script run does fetch → store → report for every tracked product, with clear log messages (Part 11) for each step and for any failure.

Acceptance checklist

  • Running the script twice in a row does not duplicate or corrupt history
  • At least one tracked product is fetched with requests + BeautifulSoup, and the code explains (in a comment or README) whether/why Playwright was needed for any of the others
  • A failed fetch for one product (site down, page changed) is logged clearly and does not stop the other products from being processed
  • The Excel report opens cleanly, has formatted headers, and visually distinguishes price drops from increases
  • The tracker respects the target sites: a delay between requests, and a check that scraping is allowed for the pages used
  • The product list (URLs) lives in a config file or list, not hard-coded inside the fetch logic

Stretch goals

  • 🟡 Email or print a one-line alert ("Price X dropped to ₹Y") when a tracked price drops below a threshold you set.
  • 🟡 A simple chart in the Excel report (openpyxl supports basic charts) showing price history for one product.
  • 🔴 Schedule the script to run automatically once a day using your OS's own scheduler (e.g. cron on Linux/macOS, Task Scheduler on Windows) — this is an operating-system feature, not a Python library, so check your OS's own documentation.
  • 🔴 Use Part 13: Concurrency to fetch multiple products at the same time instead of one after another.

How you'll know you're done

  • Every item in the acceptance checklist above is ticked
  • You can explain why you chose requests+BeautifulSoup vs. Playwright for each site
  • You can explain how the history table prevents duplicate or inconsistent rows
  • The repo is on GitHub with a README stating what it tracks, how to add a new product, and a sample of the generated report (a screenshot is enough)
  • You can demo it live: run the script and show the updated report with at least one real price change reflected

Search the guide