Skip to main content

favicon is a Python library to find a website’s favicon.

Installation

pip install favicon

Usage

Get all icons:

>>> import favicon
>>> icons = favicon.get('https://www.python.org/')
Icon(url='https://www.python.org/static/apple-touch-icon-144x144-precomposed.png', width=144, height=144, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-114x114-precomposed.png', width=114, height=114, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-72x72-precomposed.png', width=72, height=72, format='png')
Icon(url='https://www.python.org/static/apple-touch-icon-precomposed.png', width=0, height=0, format='png')
Icon(url='https://www.python.org/static/favicon.ico', width=0, height=0, format='ico')

Download largest icon:

import requests
import favicon

icons = favicon.get('https://www.python.org/')
icon = icons[0]

response = requests.get(icon.url, stream=True)
with open('/tmp/python-favicon.{}'.format(icon.format), 'wb') as image:
    for chunk in response.iter_content(1024):
        image.write(chunk)

# /tmp/python-favicon.png

Request library parameters can be passed to favicon.get() as keyword arguments:

import favicon

user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
headers = {'User-Agent': user_agent}
favicon.get('https://www.python.org/', headers=headers, timeout=2)

Requirements

Inspiration

Changelog

0.7.0 (2019-08-31)

  • Handle empty href and content attribute values (#22).

  • Support passing request library parameters to favicon.get() (#21).

    • Deprecate headers argument. Use keyword arguments: favicon.get(url, headers={‘User-Agent’; ‘my-agent’}.

0.6.0 (2019-08-10)

  • Upgrade beautifulsoup4 and requests package dependencies.

0.5.1 (2018-11-05)

  • Fix ‘NoneType’ object has no attribute ‘lower’ for meta tags (#16).

0.5.0 (2018-11-05)

  • Add support for meta tags (#15).

  • Set bs4 parser to html.parser (#13).

  • Use src package structure (#11).

0.4.1 (2018-10-01)

  • Update requirements.txt and dev-requirements.txt.

0.4.0 (2018-07-19)

  • Add support for Python 2.7 and PyPy.

  • Get icon size for New York Times (#9).

0.3.0 (2018-05-18)

  • Fav icon not found for microsoft.com (#7).

0.2.0 (2018-05-17)

  • Handle poor html values in links (#5).

  • Use given website for icon url scheme (#6).

0.1.0 (2018-05-07)

  • First release.

Download files

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

Source Distribution

favicon-0.7.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

favicon-0.7.0-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file favicon-0.7.0.tar.gz.

File metadata

  • Download URL: favicon-0.7.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

File hashes

Hashes for favicon-0.7.0.tar.gz
Algorithm Hash digest
SHA256 6d6b5a78de2a0d0084589f687f384b2ecd6a6527093fec564403b1a30605d7a8
MD5 7f5928d0cda8b6dd79b0452942fe57f5
BLAKE2b-256 6468d2646f40c05d3a501cddd232119f8c087a6fcba3c79255a062c73e80b42a

See more details on using hashes here.

File details

Details for the file favicon-0.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: favicon-0.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

File hashes

Hashes for favicon-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7fec0617c73dcb8521ea788e1d38cdc7226c7cb8e28c81e11625d85fa1534880
MD5 7c2571884d68b52cb5a81bc87b7b4a8e
BLAKE2b-256 934c8baf94bb789972634d933152d27529f2bad4e5d2397b8da9c30f6f5342ce

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 files

0.6.0

2 files

0.5.1

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page