/
View dependency graph
Depends on
- beautifulsoup4 (python3-bs4)
- dh-python (dh-python)
- python-pytest-cov (python3-pytest-cov)
- python3-defaults (python3-all)
- setuptools (python3-setuptools)
- debhelper-compat, python3-aiohttp, python3-pil
README (full)
pyfavicon
Async favicon fetcher
Requirements
Python 3.7aiohttpbeautifulsoup4Pillow
How to use
from pyfavicon import Favicon
import asyncio
from pathlib import Path
async def download_favicon():
favicon_manager = Favicon(download_dir=Path('.'),
headers={'DNT': '1'})
icons = await favicon_manager.from_url('https://gitlab.com')
# icons = await favicon_manager.from_file('my_html_file.html')
# icons = await avicon_manager.from_html('<link rel="icon" href="favicon.png">')
for icon in icons:
# We use PIL to get the exact size of images.
print("Favicon from : {}".format(icon.link))
print("Favicon export name : {}".format(icon.path))
print("Favicon size : {}".format(icon.size))
print("Favicon format: {}".format(icon.extension))
# Select the largest icon
largest_icon = icons.get_largest()
await largest_icon.save()
asyncio.run(download_favicon())
Examples
You can find a bunch of usage examples here:
| dir | debian/ |
| dir | examples/ |
| dir | pyfavicon/ |
| file | .editorconfig |
| file | .gitignore |
| file | .travis.yml |
| file | LICENSE |
| file | README.md |
| file | requirements.txt |
| file | setup.py |
| file | tox.ini |