From c1bfb5640d565b92b596ee135b88b5cbe02244f5 Mon Sep 17 00:00:00 2001 From: Alex Polo Date: Sun, 24 Aug 2025 22:22:21 +0200 Subject: [PATCH] Add docs: README, USAGE, requirements and .gitignore --- .gitignore | 15 +++++++++++++ README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++- docs/USAGE.md | 35 ++++++++++++++++++++++++++++++ requirements.txt | 5 +++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 docs/USAGE.md create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39208ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Python +__pycache__/ +*.py[cod] +.env +.venv/ +venv/ + +# PyCharm +.idea/ + +# OS +.DS_Store + +# data +results.* diff --git a/README.md b/README.md index ce47842..2c441b2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,56 @@ # newolddkprice -DBA vs PriceRunner price comparator \ No newline at end of file +DBA vs PriceRunner price comparator + +This small Python tool searches DBA (dba.dk) and PriceRunner for product +results and prints a side-by-side comparison of titles, prices and links. + +Features +- Fetch DBA search results (requests or Selenium) +- Fetch PriceRunner search results by extracting embedded JSON from the results page +- Filter results by minimum and maximum price +- Compare results in three output formats: plain text table, Markdown, or an ASCII grid + +Quick start + +Prerequisites +- Python 3.10+ (or 3.8+) +- pip + +Install dependencies (recommended in a virtualenv): + +```bash +python3 -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +``` + +Run the script (basic example): + +```bash +python3 dba_pricerunner_scraper.py "playstation 5" --pricerunner --compare --format markdown --top 8 +``` + +Common options +- `--pricerunner` : fetch PriceRunner results as well +- `--compare` : show a side-by-side comparison (requires `--pricerunner`) +- `--format` : `text` (default), `markdown`, or `grid` +- `--top N` : when used without `--compare`, prints top N DBA results; when used with `--compare` it controls number of rows in the comparison +- `--min-price` / `--max-price` : numeric filters to exclude accessories or outliers + +Examples + +- Compare PlayStation 5 results and print a Markdown table: + `python3 dba_pricerunner_scraper.py "playstation 5" --pricerunner --compare --format markdown --top 10` + +- Compare Google Pixel results and exclude accessories under 3000 DKK: + `python3 dba_pricerunner_scraper.py "google pixel 8" --pricerunner --compare --format grid --min-price 3000 --max-price 12000` + +Notes +- PriceRunner pages are parsed by extracting an embedded JSON blob. This works at time of writing but may break if the site changes. +- For very reliable scraping of JS-heavy pages, consider installing Playwright or using the Selenium renderer (the script already contains a Selenium path). + +License +This project contains a small utility script; add a license file if you plan to publish. + +More detailed usage is in `docs/USAGE.md`. \ No newline at end of file diff --git a/docs/USAGE.md b/docs/USAGE.md new file mode 100644 index 0000000..1deba31 --- /dev/null +++ b/docs/USAGE.md @@ -0,0 +1,35 @@ +# Usage + +This document expands on how to run `dba_pricerunner_scraper.py`. + +Basic invocation + +```bash +python3 dba_pricerunner_scraper.py "search terms" --pricerunner --compare --format grid --top 8 +``` + +Options + +- `--engine`: `requests` (default) or `selenium`. +- `--pricerunner`: fetch PriceRunner results. +- `--compare`: show side-by-side comparison. +- `--format`: `text` | `markdown` | `grid`. +- `--min-price` / `--max-price`: filter by price. + +Examples + +- Top 5 DBA results only: + +```bash +python3 dba_pricerunner_scraper.py "playstation 5" --top 5 +``` + +- Compare results and save markdown output: + +```bash +python3 dba_pricerunner_scraper.py "playstation 5" --pricerunner --compare --format markdown --top 10 > results.md +``` + +Notes on Selenium + +If you pick `--engine selenium`, install a compatible browser (Chrome) and ensure `chromedriver` is available. `webdriver-manager` can install the driver automatically but still requires a Chrome binary. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a3d71a3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +requests +beautifulsoup4 +lxml +webdriver-manager +selenium