https://github.com/scottwernervt/favicon
Find a website's favicon.
https://github.com/scottwernervt/favicon
favicon favicons python
Last synced: about 1 month ago
JSON representation
Find a website's favicon.
- Host: GitHub
- URL: https://github.com/scottwernervt/favicon
- Owner: scottwernervt
- License: mit
- Created: 2018-05-07T13:20:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T17:36:37.000Z (over 1 year ago)
- Last Synced: 2025-04-10T01:07:53.135Z (about 1 month ago)
- Topics: favicon, favicons, python
- Language: Python
- Homepage:
- Size: 58.6 KB
- Stars: 59
- Watchers: 3
- Forks: 15
- Open Issues: 17
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
- Authors: AUTHORS.rst
Awesome Lists containing this project
README
========
favicon
========.. start-badges
.. image:: https://img.shields.io/pypi/v/favicon.svg
:target: https://pypi.python.org/pypi/favicon.. image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: /LICENSE.. image:: https://travis-ci.org/scottwernervt/favicon.svg?branch=master
:target: https://travis-ci.org/scottwernervt/favicon.. end-badges
``favicon`` is a Python library to find a website's favicon.
Installation
============.. code-block:: bash
pip install favicon
Usage
=====Get all icons:
.. code-block:: python
>>> 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:
.. code-block:: python
import requests
import faviconicons = 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:.. code-block:: python
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
============* `requests `_
* `beautifulsoup4 `_Inspiration
===========* `pyfav `_
* `besticon `_
* `How to get high resolution website logo (favicon) for a given URL `_