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 ¶
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 ¶
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 ¶
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 ¶
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