favicon-scraper-node
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

favicon-scraper-node

A fully-typed library for quickly getting a favicon from any domain. Supports getting the favicon's meta data like image dimensions and mime types Not browser compatible

links

If you're looking to get scraped favicons in the browser, check out the wrapper to an API I host wrapper

Installation

npm install --save favicon-scraper-node

Usage

import getFavicons from 'favicon-scraper-node';

const run = async () => {
  const favicons = await getFavicons('facebook.com')
  console.log(favicons)
  /*
    [
      {
        src: "https://static.xx.fbcdn.net/rsrc.php/yb/r/hLRJ1GG_y0J.ico",
        agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
      }
    ]
  */

  const probedFavicons = await getFavicons('facebook.com', {
    probe: true
  })
  console.log(probedFavicons)
  /*
    [
      {
        src: "https://static.xx.fbcdn.net/rsrc.php/yb/r/hLRJ1GG_y0J.ico",
        size: {
          width: 32,
          height: 32,
        },
        type: "ico",
        mime: "image/x-icon",
        agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
      }
    ]
  */
}

Options

const options: FaviconOptions = {
  agent: 'mobile_ios', // 'mobile_ios' | 'mobile_android' | 'desktop_chrome' | 'desktop_safari'
  manifest: false,  // Get the icons from the manifest.json
  scraper: 'fetch',
  probe: true
}
const favicons = await getFavicons('facebook.com', options)

Package Sidebar

Install

npm i favicon-scraper-node

Weekly Downloads

0

Version

0.3.0

License

ISC

Unpacked Size

13.9 kB

Total Files

17

Last publish

Collaborators

  • harvmaster