Favicon

Get the favicon for any web

favicon.js
const mql = require('@microlink/mql')

const favicon = async (url, opts) => {
  const { data } = await mql(url, {
    meta: false,
    data: {
      favicon: [
        {
          selector: 'link[href*="favicon.ico"]',
          attr: 'href',
          type: 'image'
        },
        {
          selector: 'link[type="image/x-icon"]',
          attr: 'href',
          type: 'image'
        }
      ]
    },
    ...opts
  })

  return data.favicon
}

const result = await favicon('https://microlink.io')

mql.render(result)