Skip to main content
Internal Service β€” This is not an HTTP endpoint. It’s called by the enhanced logo service.

Purpose

Downloads the favicon from a website using multiple fallback methods.

Function Signature

async def fetch_favicon(website_url: str) -> Optional[dict]

Parameters

ParameterTypeDescription
website_urlstrThe website URL to fetch favicon from

Returns

{
    "bytes": b"...",      # Raw favicon bytes
    "png_bytes": b"...",  # Converted to PNG
    "url": "https://..."  # Source URL
}
Returns None if no favicon found.

Favicon Discovery Order

  1. Parse HTML - Look for <link rel="icon"> tags
  2. Common paths - Try /favicon.ico, /favicon.png, /apple-touch-icon.png
  3. Google fallback - https://www.google.com/s2/favicons?domain={domain}&sz=256

Code Location

src/website/enhanced_logo/service.py
# Lines 70-167: fetch_favicon()