Return the first plausible external homepage URL from an HTML page.
(html_text: str, base_url: str = "")
| 800 | |
| 801 | |
| 802 | def _extract_external_homepage_url(html_text: str, base_url: str = "") -> str: |
| 803 | """Return the first plausible external homepage URL from an HTML page.""" |
| 804 | for match in re.finditer(r'<a\b[^>]*href=["\'](.*?)["\']', html_text or "", re.IGNORECASE | re.DOTALL): |
| 805 | raw_href = html.unescape(_collapse_whitespace(match.group(1))) |
| 806 | if not raw_href: |
| 807 | continue |
| 808 | resolved = urljoin(base_url or "", raw_href) |
| 809 | parsed = urlsplit(resolved) |
| 810 | if parsed.scheme not in {"http", "https"}: |
| 811 | continue |
| 812 | netloc = (parsed.netloc or "").casefold() |
| 813 | if not netloc or "scholar.google." in netloc or "google." == netloc: |
| 814 | continue |
| 815 | if any(token in resolved.casefold() for token in ("/citations?", "/scholar?", "view_op=")): |
| 816 | continue |
| 817 | return resolved |
| 818 | return "" |
| 819 | |
| 820 | |
| 821 | def _parse_google_scholar_profile_html(html_text: str) -> Dict[str, Any]: |
no test coverage detected