Fetch page content. Returns (status_code, html_text).
(url: str, max_bytes: int = 8000)
| 80 | |
| 81 | |
| 82 | def fetch_page(url: str, max_bytes: int = 8000) -> tuple[int, str]: |
| 83 | """Fetch page content. Returns (status_code, html_text).""" |
| 84 | try: |
| 85 | req = Request(url, headers=HEADERS) |
| 86 | resp = urlopen(req, timeout=15) |
| 87 | content = resp.read(max_bytes).decode("utf-8", errors="ignore") |
| 88 | return resp.status, content |
| 89 | except HTTPError as e: |
| 90 | return e.code, "" |
| 91 | except (URLError, OSError) as e: |
| 92 | return 0, str(e) |
| 93 | |
| 94 | |
| 95 | def check_iso(standard: dict) -> dict | None: |
no outgoing calls
no test coverage detected