favicon is a Python library designed to find and extract a website's favicon. It simplifies the process of locating favicons, which can be in various locations on a website. The current version is 0.7.0, released in August 2019. The release cadence appears to be infrequent.
pip install faviconVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `favicon` library and use its `get()` function to retrieve a list of `Favicon` objects for a given URL. It then prints the URL and dimensions of the first found favicon.
Instead of `favicon.get(url, headers={'User-Agent': 'my-agent'})`, pass keyword arguments directly to the function, e.g., `favicon.get(url, user_agent='my-agent')` or `favicon.get(url, **{'headers': {'User-Agent': 'my-agent'}})` if you need to pass a dictionary of headers.For websites where `favicon.get()` fails to find icons, manually inspect the page's HTML `<head>` for `<link rel="icon" ...>` tags or try a more robust, actively developed favicon extraction library like `extract-favicon` if more advanced features (e.g., async support, size guessing, DuckDuckGo/Google API fallbacks) are needed.
Always check if the `icons` list is not empty before attempting to access elements like `icons[0]`. Iterate through the list if you need to inspect all available favicons or apply logic to select the 'best' one based on your criteria (e.g., largest size).
No dependency data recorded yet.