feat: single-line progress indicator during crawl and ext-link check

Uses \r to overwrite the same terminal line — no scrolling.
Crawler exposes on_progress callback; checker.check_external_links
gets an optional on_progress parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-06-12 17:17:37 +02:00
commit 792ca67c08
3 changed files with 35 additions and 1 deletions

View file

@ -123,6 +123,7 @@ def check_external_links(
urls: list[str],
timeout: int = 10,
delay: float = 0.3,
on_progress: object = None,
) -> dict[str, dict]:
"""
Check a list of URLs for reachability via HEAD (fallback: GET).
@ -158,6 +159,8 @@ def check_external_links(
results[url] = {"status": resp.status_code, "final_url": resp.url, "error": None}
except requests.exceptions.RequestException as exc:
results[url] = {"status": None, "final_url": None, "error": str(exc)}
if on_progress:
on_progress(i + 1, len(urls))
finally:
session.close()