npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrap-favicon

v1.0.4

Published

Get favicon urls and its meta information as json

Downloads

13

Readme

Get favicons list from a website

scrap-favicon Build Status npm version

Get favicon urls without downloading it along with its meta information using scrap-favicon

Introduction

The main aim of this package is to greedily fetch/scrap all the favicons and their dimensions without downloading it completely. (a few chunks can give correct dimensions).

  1. This package scraps/fetch the favicon from the website in two steps:
    1. Check the meta information declared.
    2. Add default favicon url (/favicon.ico & /apple-touch-icon.png) and check if resource present.
  2. Download each url in chunks just to obtain favicon dimensions information using image-size package.

Install

$ npm install scrap-favicon

Usage

const scrapFavicon = require('scrap-favicon');

// Fetching all meta information of favicon
scrapFavicon('https://akansh.com').then(resp => console.log(resp), err => console.error(err));

// Fetching only urls of favicon
scrapFavicon('https://akansh.com', {
    urlsOnly: true
}).then(resp => console.log(resp), err => console.error(err));

// Setting timeout(ms) and number of redirects for website url
scrapFavicon('https://akansh.com', {
    timeout: 10000,
    maxRedirect: 2
}).then(resp => console.log(resp), err => console.error(err));

You can check examples here.

API

scrapFavicon(url, config?)

url

Type: string

A url of the website whose favicon details needs to be scrapped

config

Type: object

urlsOnly

Type: Boolean Default: false

Returns only the list of the urls without meta information of favicon

timeout

Type: Number Default: 100000

Number of milliseconds before waiting for website url to be fetched PS: In case of redirect, each redirected url will have its own timeout

maxRedirects

Type: Number Default: 10

Max number of redirects allowed before reaching to website url due to 301 or 302 redirects

Example

const scrapFavicon = require('scrap-favicon');

// Fetching all meta information of favicon
scrapFavicon('https://akansh.com').then(resp => console.log(resp), err => console.error(err));
/*
Result -> 
{   
    redirects: 
     [{ url: 'https://www.akansh.com/',
         timeTaken: 1140.6958409547806      // ms taken to redirect  
      }],
    images: 
     [ { url: 'https://www.akansh.com/icons/icon-48x48.png',
         scrapped: true,        // true means it has been scrapped from the website
         width: 48,             // width of the favicon image
         height: 48,            // height of the favicon image
         type: 'png',           // type of the favicon e.g. jpg, png, ico
         chunkSize: 1447,       // the size downloaded to find the meta information of the image 
         success: true },     
       { url: 'https://www.akansh.com/favicon.ico',
         scrapped: false,       // false means it was not declared on website but still available
         width: 439,
         height: 439,
         type: 'svg',
         chunkSize: 81676,
         success: true },
       { url: 'https://www.akansh.com/apple-touch-icon.png',
         scrapped: false,
         width: 439,
         height: 439,
         type: 'svg',
         chunkSize: 81676,
         success: true } ],
    timeTaken: 2341.6667330265045 
}

*/