{"id":5222,"library":"favicon","title":"Favicon Extractor","description":"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.","status":"maintenance","version":"0.7.0","language":"en","source_language":"en","source_url":"https://github.com/scottwernervt/favicon","tags":["web scraping","favicon","utility","website","icon"],"install":[{"cmd":"pip install favicon","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The primary function `get` is typically accessed via the main `favicon` module.","wrong":"from favicon import get","symbol":"get","correct":"import favicon\nicons = favicon.get(url)"}],"quickstart":{"code":"import favicon\n\n# Example URL\nurl = \"https://www.google.com\"\n\n# Get all favicons for the URL\nicons = favicon.get(url)\n\n# The 'icons' variable is a list of Favicon objects.\n# Each Favicon object has attributes like .url, .width, .height, .format.\n\nif icons:\n    # Print the URL of the first (and often best) favicon\n    print(f\"Found favicon URL: {icons[0].url}\")\n    # You can also access other properties\n    print(f\"Size: {icons[0].width}x{icons[0].height}\")\nelse:\n    print(f\"No favicons found for {url}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"The `headers` argument in `favicon.get()` was deprecated in version 0.7.0. Passing a dictionary directly to `headers` will not work as expected.","severity":"deprecated","affected_versions":"0.7.0 and later"},{"fix":"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.","message":"The `favicon` library has not been updated since August 2019. While it generally works, it might not handle all modern favicon detection methods or edge cases found on newer websites. Consider alternative, more actively maintained libraries for complex scenarios.","severity":"gotcha","affected_versions":"0.7.0"},{"fix":"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).","message":"The `favicon.get()` function returns a list of `Favicon` objects. It is common to assume only one favicon exists or to directly access `icons[0]`. However, a website might provide multiple favicons (e.g., different sizes, formats).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}