Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BlackGlory/parse-favicon
🌳 Parse HTML to get icon information
https://github.com/BlackGlory/parse-favicon
library nodejs npm-package typescript
Last synced: about 1 month ago
JSON representation
🌳 Parse HTML to get icon information
- Host: GitHub
- URL: https://github.com/BlackGlory/parse-favicon
- Owner: BlackGlory
- License: mit
- Created: 2016-11-19T03:58:28.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-26T15:00:41.000Z (9 months ago)
- Last Synced: 2024-10-01T09:48:38.871Z (2 months ago)
- Topics: library, nodejs, npm-package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/parse-favicon
- Size: 1.38 MB
- Stars: 49
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-list - parse-favicon
README
# parse-favicon
Parse HTML to get icon information.## Install
```sh
npm install --save parse-favicon
# or
yarn add parse-favicon
```## Usage
```js
import { parseFavicon } from 'parse-favicon'const pageURL = 'https://github.com'
parseFavicon(pageURL, fetchText, fetchBuffer)
.subscribe(icon => console.log(icon))function fetchText(url: string): Promise {
return fetch(url)
.then(res => res.text())
}function fetchBuffer(url: string): Promise {
return fetch(url)
.then(res => res.arrayBuffer())
}
```## API
### parseFavicon
```ts
type TextFetcher = (url: string) => Awaitable // string | PromiseLike
type BufferFetcher = (url: string) => Awaitable // ArrayBuffer | PromiseLikeinterface IIcon {
url: string
reference: string
type: null | string
size: null | 'any' | ISize | ISize[]
}interface ISize {
width: number
height: number
}function parseFavicon(
pageURL: string
, textFetcher: TextFetcher
, bufferFetcher?: BufferFetcher
): Observable
````parseFavicon` accepts `textFetcher` and `bufferFetcher` for further fetching requests when parsing icons, `bufferFetcher` is optional.
If you need actual icon sizes and type, should provide `bufferFetcher`.References related to `textFetcher`:
- ``
- ``References related to `bufferFetcher`:
- `/favicon.ico`
- `/apple-touch-icon-57x57-precomposed.png`
- `/apple-touch-icon-57x57.png`
- `/apple-touch-icon-72x72-precomposed.png`
- `/apple-touch-icon-72x72.png`
- `/apple-touch-icon-114x114-precomposed.png`
- `/apple-touch-icon-114x114.png`
- `/apple-touch-icon-120x120-precomposed.png`
- `/apple-touch-icon-120x120.png`
- `/apple-touch-icon-144x144-precomposed.png`
- `/apple-touch-icon-144x144.png`
- `/apple-touch-icon-152x152-precomposed.png`
- `/apple-touch-icon-152x152.png`
- `/apple-touch-icon-180x180-precomposed.png`
- `/apple-touch-icon-180x180.png`
- `/apple-touch-icon-precomposed.png`
- `/apple-touch-icon.png`## Supported references
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- ``
- `/favicon.ico`
- `/apple-touch-icon-57x57-precomposed.png`
- `/apple-touch-icon-57x57.png`
- `/apple-touch-icon-72x72-precomposed.png`
- `/apple-touch-icon-72x72.png`
- `/apple-touch-icon-114x114-precomposed.png`
- `/apple-touch-icon-114x114.png`
- `/apple-touch-icon-120x120-precomposed.png`
- `/apple-touch-icon-120x120.png`
- `/apple-touch-icon-144x144-precomposed.png`
- `/apple-touch-icon-144x144.png`
- `/apple-touch-icon-152x152-precomposed.png`
- `/apple-touch-icon-152x152.png`
- `/apple-touch-icon-180x180-precomposed.png`
- `/apple-touch-icon-180x180.png`
- `/apple-touch-icon-precomposed.png`
- `/apple-touch-icon.png`## Related projects
- [favicon-detector](https://github.com/BlackGlory/favicon-detector)