Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bilelmoussaoui/pyfavicon

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bilelmoussaoui/pyfavicon

  • v0.0.0-20220411182222-ebc74bd3face
  • Source
  • Go
  • Socket score

Version published
Created
Source

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:

FAQs

Package last updated on 11 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc