Public Good Studio offers technical, design and fabrication services.
Let's collaborate to explore new ways of thinking and to setup outposts in recently charted lands.
pyfav
pyfav is simple, and simple to use
About
Favicons are the small icons that show up in a web browser's tab when you navigate to a page.
They can be annoying to programmatically retrieve because they’re commonly located in a handful of different places. pyfav is a Python library that removes the annoyance by handling the details for you – you supply a URL and pyfav will give you the favicon.
What's so great about a favicon?
Favicons are fascinating because of the tight constraint they enforce. They ask an organization to represent their identity in one 16 pixel by 16 pixel image.
This constraint surfaces things about the organization. Do they value their logo over a more abstract representation? Maybe the first letter of their organization's name is most important. What colors do they use to represent themselves? This scarcity of space can be revealing.
Source Code
Source code is available through a dual MIT/GPL license on GitHub.
Check it out
Install and read more about pyfav at PyPI
The easiest way to get started is to use the download_favicon function,
from pyfav import download_favicon favicon_saved_at = download_favicon('https://www.python.org/')
You should now see the favicon in your /tmp directory. If you want to control where the favicon gets written to disk,
from pyfav import download_favicon import os os.mkdir('/tmp/favicon-downloads') favicon_saved_at = download_favicon('https://www.python.org/', \ file_prefix='python.org-', target_dir='/tmp/favicon-downloads')
Get the location
If you’d prefer to only get the location of the favicon, use the get_favicon_url function,
from pyfav import download_favicon favicon_url = get_favicon_url('https://www.python.org/')
Install
The easiest way to get pyfav is through PIP
pip install pyfav