MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _extract_external_homepage_url

Function _extract_external_homepage_url

agents/coldstart-agent/main.py:802–818  ·  view source on GitHub ↗

Return the first plausible external homepage URL from an HTML page.

(html_text: str, base_url: str = "")

Source from the content-addressed store, hash-verified

800
801
802def _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
821def _parse_google_scholar_profile_html(html_text: str) -> Dict[str, Any]:

Callers 1

Calls 1

_collapse_whitespaceFunction · 0.85

Tested by

no test coverage detected