| 13 | |
| 14 | |
| 15 | class _BodyTextParser(HTMLParser): |
| 16 | def __init__(self) -> None: |
| 17 | super().__init__() |
| 18 | self._parts: list[str] = [] |
| 19 | |
| 20 | def handle_data(self, data: str) -> None: |
| 21 | text = data.strip() |
| 22 | if text: |
| 23 | self._parts.append(text) |
| 24 | |
| 25 | def get_text(self) -> str: |
| 26 | return "\n".join(self._parts) |
| 27 | |
| 28 | |
| 29 | def read_html(url: str) -> str: |