Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
favicon
is a Python library to find a website's favicon.
.. code-block:: bash
pip install favicon
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 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)
Request library <https://2.python-requests.org/>
_ 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)
requests <http://docs.python-requests.org/>
_beautifulsoup4 <https://www.crummy.com/software/BeautifulSoup/bs4/doc/>
_pyfav <https://github.com/phillipsm/pyfav>
_besticon <https://github.com/mat/besticon/>
_How to get high resolution website logo (favicon) for a given URL <https://stackoverflow.com/questions/21991044/how-to-get-high-resolution-website-logo-favicon-for-a-given-url>
_Handle empty href
and content
attribute values (#22 <https://github.com/scottwernervt/favicon/issues/22>
_).
Support passing request library parameters to favicon.get()
(#21 <https://github.com/scottwernervt/favicon/issues/21>
_).
headers
argument. Use keyword arguments: favicon.get(url, headers={'User-Agent'; 'my-agent'}
.beautifulsoup4
and requests
package dependencies.#16 <https://github.com/scottwernervt/favicon/issues/16>
_).#15 <https://github.com/scottwernervt/favicon/pull/15>
_).html.parser
(#13 <https://github.com/scottwernervt/favicon/issues/13>
_).src
package structure (#11 <https://github.com/scottwernervt/favicon/issues/11>
_).requirements.txt
and dev-requirements.txt
.#9 <https://github.com/scottwernervt/favicon/issues/9>
_).#7 <https://github.com/scottwernervt/favicon/issues/7>
_).#5 <https://github.com/scottwernervt/favicon/issues/5>
_).#6 <https://github.com/scottwernervt/favicon/issues/6>
_).FAQs
Get a website's favicon.
We found that favicon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.