1.0.0 • Published 4 years ago

@dkh-dev/html-metadata-parser v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

html-metadata-parser

HTML Metadata Parser

Parser rules from mozilla/page-metadata-parser.

Installation

npm install @dkh-dev/html-metadata-parser

Examples

'use strict'

const { parse } = require('@dkh-dev/html-metadata-parser')

const url = 'https://github.com/'
const html = `
<!DOCTYPE html>
<html>

<head>
  <title>GitHub</title>
  <meta name="description" content="GitHub is where people build software.">
</head>

<!-- ... -->

</html>`

const main = async () => {
  const metadata = await parse(url, html)

  console.log(metadata)
  // => {
  //      url: 'https://github.com/',
  //      icon: 'https://github.com/favicon.ico',
  //      provider: 'github.com',
  //      title: 'GitHub',
  //      description: 'GitHub is where people build software.'
  //    }
}

main()