getfavicon

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: MIT Imports: 16 Imported by: 1

Documentation

Overview

getfavicon package get and download all favicons of given websites.

Doc to install and use the loadfavicon command: https://pkg.go.dev/github.com/lolorenzo777/loadfavicon#section-documentation

Doc to use the getfavicon package: https://pkg.go.dev/github.com/lolorenzo777/loadfavicon/getfavicon#section-documentation

Get and import the package to your project:

$ go get github.com/lolorenzo777/loadfavicon/getfavicon

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SlugHost added in v1.2.1

func SlugHost(website string) string

SlugHost slugify the website URL

Types

type TFavicon

type TFavicon struct {
	Website      url.URL // The absolute URL of the favicon's host website
	Webicon      url.URL // The absolute URL of the favicon's file
	DiskFileName string  // The disk file name, based on the slugyfied website URL and the favicon url name
	Color        string  // Color specfications if any specified in the <link> node
	Size         string  // Size specfications if any specified in the <link> node
	Image        []byte  // The loaded raw image
}

func Download

func Download(website string, toDir string, single bool) (favicons []TFavicon, err error)

Download loads all favicons files related to a website and store them locally to the 'toDir' directoty. Files are saved with name prefixed by savePrefix. Existing dest file are replaced. 'toDir' parameter can't be an empty name.

Set 'single' parameter to download only one favicon (see SelectSingleFavicon for the selection rule)

Returns the slice of successfully downloded Favicons

func ReadAll

func ReadAll(website string) (favicons []TFavicon, err error)

ReadAll gets all favicons of a single website in memory.

Favicon's urls returned by getFaviconLinks are scanned. Only files correspnding to valid image MIME formats (defined in var acceptedMIMEtypes) are returned. Duplicates are ignored.

func SelectSingle

func SelectSingle(favicons []TFavicon) (single *TFavicon)

SelectSingle selects a single favicon from favicons based on a simple rule. It selects .svg if any or selects the bigest size one if multiples one exists, finaly get the .ico if it exists Call LoadAll favicons before to build []TFavicon

Returns nil if favicons was empty

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL