Extract base host from URL. Args: url: Full URL to parse Returns: str: Base host in format 'scheme://hostname' Example: 'http://example.com/path' -> 'http://example.com'
(self, url: str)
| 393 | self.redirect_cache.clear() |
| 394 | |
| 395 | def get_base_host(self, url: str) -> str: |
| 396 | """ |
| 397 | Extract base host from URL. |
| 398 | |
| 399 | Args: |
| 400 | url: Full URL to parse |
| 401 | |
| 402 | Returns: |
| 403 | str: Base host in format 'scheme://hostname' |
| 404 | |
| 405 | Example: |
| 406 | 'http://example.com/path' -> 'http://example.com' |
| 407 | """ |
| 408 | try: |
| 409 | parsed = urlparse(url) |
| 410 | return f"{parsed.scheme}://{parsed.netloc}" |
| 411 | except Exception as e: |
| 412 | logging.error(f"Error extracting base host: {e}") |
| 413 | return url |
| 414 | |
| 415 | def download(self, url: str) -> tuple[bytes, str]: |
| 416 | """ |