feat: exclude_paths — skip dynamic areas (RSS feeds, news archives) from scan
Adds crawl.exclude_paths config option (list of URL path prefixes).
Matching URLs are excluded at two levels:
- Crawler: not fetched at all (saves HTTP requests)
- Differ: filtered from both baseline and current before comparison,
so legacy baseline entries under excluded paths don't appear as
"missing URLs" after the option is added retroactively
Example config:
crawl:
exclude_paths: ["/rss/", "/feed/", "/news/archiv/"]
8 new tests (176 total).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b01344dcd8
commit
3a44cfb515
6 changed files with 93 additions and 2 deletions
|
|
@ -12,6 +12,14 @@ from urllib.parse import urlparse
|
|||
# Normalisation
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _is_excluded(url: str, exclude_paths: list[str]) -> bool:
|
||||
"""Return True if the URL's path starts with any of the configured exclude prefixes."""
|
||||
if not exclude_paths:
|
||||
return False
|
||||
path = urlparse(url).path
|
||||
return any(path.startswith(ep) for ep in exclude_paths)
|
||||
|
||||
|
||||
def normalize_text(text: str, cfg: dict) -> str:
|
||||
"""Apply noise-reduction before diffing."""
|
||||
norm_cfg = cfg.get("normalization", {})
|
||||
|
|
@ -103,6 +111,11 @@ def compare_snapshots(baseline_pages: dict, current_pages: dict, cfg: dict) -> d
|
|||
page_diffs (list of per-page change records),
|
||||
new_pages_analysis (freshly seen pages checked for immediate issues)
|
||||
"""
|
||||
excl = cfg.get("crawl", {}).get("exclude_paths", [])
|
||||
if excl:
|
||||
baseline_pages = {u: p for u, p in baseline_pages.items() if not _is_excluded(u, excl)}
|
||||
current_pages = {u: p for u, p in current_pages.items() if not _is_excluded(u, excl)}
|
||||
|
||||
b_urls = set(baseline_pages)
|
||||
c_urls = set(current_pages)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue