Data and analytics

Daily rental listings scraper with neighbourhood price chart

Python script that collects city rental listings daily and charts average price per neighbourhood, with a verify skill and phased goal prompts.

pythonpytestruffmypysqlite

Built 1 time, downloaded 0 times.

Install from your terminal

Run this in your project folder. It signs you in, shows what changes and asks before it overwrites a file.

npx claude-lab add daily-rental-listings-scraper-with-neighbourhood-price-chart-663aa0
10 filesDownload zip
CLAUDE.md
# Rental tracker

## Purpose

Collect rental listings for one city once a day, store them locally, and chart the average price per neighbourhood. Solo project, Python script, no web service.

## Commands

- Create venv: `python -m venv .venv`
- Activate venv: `source .venv/bin/activate` (macOS or Linux) or `.venv\Scripts\activate` (Windows)
- Install: `pip install -r requirements.txt`
- Run tests: `pytest -q`
- Lint: `ruff check .`
- Type check: `mypy src`
- Run collector: `python -m rentals.collect`
- Render chart: `python -m rentals.chart`

## Layout

- `src/rentals/`: package code
- `tests/`: pytest tests
- `tests/fixtures/`: saved HTML used by tests
- `data/`: raw HTML cache and history database (gitignored)
- `output/`: PNG charts and CSV summaries (gitignored)
- `SPEC.md`: what the collector and chart must do
- `PLAN.md`: phases and their goal prompts
- `REVIEW.md`: review rules, imported below

@REVIEW.md

## Scraping rules

- Check robots.txt and the site's terms before adding or changing a source.
- Set a descriptive User-Agent that names the project and gives a contact route.
- Sleep at least 2 seconds between requests to the same site.
- Cache raw HTML responses in `data/` so re-runs do not refetch.
- Stop and report on 403 or 429. Do not retry in a loop.
- Do not add login, CAPTCHA handling, or collection of personal contact data.

## Testing rules

- Tests read saved HTML from `tests/fixtures/`. Never make live requests in tests.
- When a parser changes, update or add its fixture and its test together.
- Run `verify` (the project skill) before reporting a change as done.

## Data conventions

- Store prices as integer currency units per month.
- Record the currency alongside each price.
- Record whether utilities are included, as a nullable field. Use None when the listing does not say.
- Missing fields become None. They must not crash the parser.
- Timestamps are UTC.
- Any schema change needs a migration note in PLAN.md before the code lands.

## Secrets

- Put any API key or proxy credential in `.env`, using `YOUR_API_KEY=placeholder` as the template line.
- Never commit `.env`. Confirm `.gitignore` lists `.env`, `data/` and `output/`.
- Do not print secrets in logs or test output.

## Gotchas

- `ruff` or `pytest` not found usually means the venv is not activated.
- Keep the chart threshold (minimum listings per neighbourhood, default 5) in one constant. Do not hard-code it elsewhere.
- Neighbourhoods below the threshold are left out of the chart and listed in a footnote.

## Conventions

- Keep diffs small. Flag unrelated refactors instead of making them.
- Ask before adding a dependency beyond pytest, ruff and mypy.
- Ask before changing the scheduler setup (cron or Task Scheduler).
- Use sentence case in comments and docs.
Use for my project