URLicon helps you to discover an possible icon from a URL.
We check for the metatag icons, favicons and, if we don't find, we check the
first image in the URL html code. Finally, if nothing is found, we use the
https://ui-avatars.com/api/ to bring you at least
some avatar-like icon.
Install with uv or pip
uv add urlicon
# or
pip urliconUsage:
from urlicon import urlicon
url = "https://this-is.your-url.com/some-path"
icon_url = urlicon.get_url_icon(url)
print("icon:", icon_url)
# icon: "https://this-is.your-url.com/icon.jpeg"URLicon use the unforgettable "cache" to avoid unecessary URL requests.
It uses a temp dir for each
execution. But you can define a your own directory and use the cache as much as
you want setting SIMPLE_CACHE_ROOT_DIR env var.
SIMPLE_CACHE_ROOT_DIR = os.getenv("SIMPLE_CACHE_ROOT_DIR", None)
cache = unforgettable(cache_folder=SIMPLE_CACHE_ROOT_DIR)And you can clean the cache with:
urlicon.unforgettable.clean()This package is distributed under the MIT license.