Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Async favicon fetcher

Project description

pyfavicon

Build Status Coverage Status https://pypi.org/project/pyfavicon/ https://pypi.org/project/pyfavicon/ https://bilelmoussaoui.github.io/pyfavicon/

Async favicon fetcher

Requirements

  • Python 3.7
  • aiohttp
  • beautifulsoup4
  • Pillow

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyfavicon, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size pyfavicon-0.1.1-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyfavicon-0.1.1.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page