INNER CODE UNIT · Python

_get_favicon_from_soup

stratumauth/app · extra/generate_icon_meta.py:85

def _get_favicon_from_soup(base_url: str, soup: bs4.BeautifulSoup) -> Optional[str]:
    link_tags = soup.find_all("link")

    for tag in link_tags:
        if tag.has_attr("rel") and any(
            rel in {"icon", "apple-touch-icon"} for rel in tag.get("rel")
        ):
            href = tag.get("href")

            if href.startswith("data:image"):
                continue

            if href.startswith("http"):
                return href

            if href.startswith("www."):
                return f"https://{href}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…