Fetch *url* and return decoded text (UTF-8, replacing bad bytes). Wraps safe_fetch with tighter defaults for HTML / text content.
(url: str, max_bytes: int = _MAX_TEXT_BYTES, timeout: int = 15)
| 315 | |
| 316 | |
| 317 | def safe_fetch_text(url: str, max_bytes: int = _MAX_TEXT_BYTES, timeout: int = 15) -> str: |
| 318 | """Fetch *url* and return decoded text (UTF-8, replacing bad bytes). |
| 319 | |
| 320 | Wraps safe_fetch with tighter defaults for HTML / text content. |
| 321 | """ |
| 322 | raw = safe_fetch(url, max_bytes=max_bytes, timeout=timeout) |
| 323 | return raw.decode("utf-8", errors="replace") |
| 324 | |
| 325 | |
| 326 | # --------------------------------------------------------------------------- |