|
1 | 1 | # breach-web-scraper |
2 | | -A Python tool for scraping breach websites to provide a nice summary. |
3 | 2 |
|
4 | | -## WA AG scraper (initial source) |
5 | | -This repository now includes a scraper for Washington Attorney General data breach notifications: |
| 3 | +[](https://github.com/noderaven/breach-web-scraper/actions/workflows/ci.yml) |
| 4 | +[](LICENSE) |
| 5 | +[](pyproject.toml) |
6 | 6 |
|
7 | | -- Source URL: `https://www.atg.wa.gov/data-breach-notifications` |
8 | | -- Script: `scraper/wa_atg_scraper.py` |
| 7 | +A Python tool for scraping breach websites to provide a nice summary. The first |
| 8 | +supported source is the Washington State Attorney General data breach |
| 9 | +notifications page. Runtime dependencies: none (standard library only). |
| 10 | + |
| 11 | +## Install |
9 | 12 |
|
10 | | -### Usage |
11 | 13 | ```bash |
12 | | -python scraper/wa_atg_scraper.py --output json --limit 10 |
13 | | -python scraper/wa_atg_scraper.py --output markdown --out-file wa_breaches.md |
14 | | -python scraper/wa_atg_scraper.py --output csv --out-file wa_breaches.csv |
| 14 | +pip install . |
15 | 15 | ``` |
16 | 16 |
|
17 | | -### Output fields |
18 | | -The parser normalizes column names from the HTML table to `snake_case`. For cells containing links, it also emits a `<column>_url` field. |
| 17 | +This installs the `breach-scraper` console command. |
19 | 18 |
|
20 | | -### Known hurdles / maintenance notes |
21 | | -- The scraper depends on the page containing a parseable HTML table. |
22 | | -- If WA AG changes table structure or field names, parsing/normalization may need updates. |
23 | | -- For production automation, add retries/backoff, persistence, and monitoring around this script. |
| 19 | +## Usage |
24 | 20 |
|
25 | | -### Tests |
26 | 21 | ```bash |
27 | | -python -m unittest discover -s tests |
| 22 | +# Fetch live and print JSON (default), limited to 10 rows |
| 23 | +breach-scraper --output json --limit 10 |
| 24 | + |
| 25 | +# Markdown / CSV to a file |
| 26 | +breach-scraper --output markdown --out-file wa_breaches.md |
| 27 | +breach-scraper --output csv --out-file wa_breaches.csv |
| 28 | + |
| 29 | +# Offline: parse a previously saved page (no network) |
| 30 | +breach-scraper --input-html saved_page.html --output json |
| 31 | + |
| 32 | +# Override the User-Agent or retry count |
| 33 | +breach-scraper --user-agent "my-agent/1.0" --retries 5 |
28 | 34 | ``` |
| 35 | + |
| 36 | +If the source returns HTTP 403, the tool prints an actionable message; use |
| 37 | +`--input-html` with a saved copy of the page, a different network, or a |
| 38 | +different `--user-agent`. |
| 39 | + |
| 40 | +## Output fields |
| 41 | + |
| 42 | +Column names from the HTML table are normalized to `snake_case`. Cells that |
| 43 | +contain links also emit a `<column>_url` field. |
| 44 | + |
| 45 | +## Development |
| 46 | + |
| 47 | +```bash |
| 48 | +pip install -e ".[dev]" |
| 49 | +ruff check . |
| 50 | +ruff format --check . |
| 51 | +mypy |
| 52 | +bandit -r breach_scraper |
| 53 | +python -m unittest discover -s tests -v |
| 54 | +``` |
| 55 | + |
| 56 | +## Source / maintenance notes |
| 57 | + |
| 58 | +- Source URL: `https://www.atg.wa.gov/data-breach-notifications` |
| 59 | +- The scraper depends on the page exposing a parseable HTML table; if the WA AG |
| 60 | + changes the table structure or field names, parsing may need updates. |
0 commit comments