Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bilelmoussaoui/pyfavicon
Async favicon fetcher
https://github.com/bilelmoussaoui/pyfavicon
Last synced: 3 months ago
JSON representation
Async favicon fetcher
- Host: GitHub
- URL: https://github.com/bilelmoussaoui/pyfavicon
- Owner: bilelmoussaoui
- License: mit
- Created: 2019-06-03T11:42:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-11T18:22:22.000Z (over 2 years ago)
- Last Synced: 2024-10-05T07:38:30.716Z (3 months ago)
- Language: Python
- Size: 56.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyfavicon
[![Build Status](https://travis-ci.org/bilelmoussaoui/pyfavicon.svg?branch=master)](https://travis-ci.org/bilelmoussaoui/pyfavicon)
[![Coverage Status](https://coveralls.io/repos/github/bilelmoussaoui/pyfavicon/badge.svg?branch=master)](https://coveralls.io/github/bilelmoussaoui/pyfavicon)
[![https://pypi.org/project/pyfavicon/](https://img.shields.io/pypi/v/pyfavicon.svg)](https://pypi.org/project/pyfavicon/)
[![https://pypi.org/project/pyfavicon/](https://img.shields.io/pypi/pyversions/pyfavicon.svg)](https://pypi.org/project/pyfavicon/)
[![https://bilelmoussaoui.github.io/pyfavicon/](https://img.shields.io/badge/-docs-blue.svg)](https://bilelmoussaoui.github.io/pyfavicon/)Async favicon fetcher
### Requirements
- `Python 3.7`
- `aiohttp`
- `beautifulsoup4`
- `Pillow`### How to use
```python
from pyfavicon import Favicon
import asyncio
from pathlib import Pathasync 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('')
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:
- [Gtk Application](examples/gtk_app.py)