1.0.12 • Published 1 year ago

fetch-meta-tags v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm version code style: prettier

fetch-meta-tags

Fetch and parse OG tags and metadata from any URL, the fast way

Why

I wanted a way to quickly fetch OG tags from websites and get their title, description, icon and OG image. I found all existing solutions not to be ideal because:

  • They had unnecessary dependencies, increasing bundle size
  • They fetch the whole body of the website, increasing load time

fetch-meta-tags solves those problems by:

  • Having just two dependencies: node-fetch and node-html-parser. They are both very lightweight libraries and also very fast
  • Streaming websites and stopping the HTTP request once </head> is received. No need to fetch the whole HTML of the website

Installation

$ yarn add fetch-meta-tags
$ npm install --save fetch-meta-tags

Usage

import fetchMeta from 'fetch-meta-tags'

await fetchMeta('https://luisc.xyz')

Outputs:

{
  url: 'https://luisc.xyz',
  title: 'Luis Cuende',
  description: 'Musings about modern philosophy, productivity and unbundling the nation state with crypto/Web3.',
  icon: 'https://luisc.xyz/favicon.ico',
  image: 'https://luisc.xyz/logo.jpg'
}

Credits

https://github.com/mozilla/page-metadata-parser for the meta tag ruleset.s

License

MIT License

1.0.11

1 year ago

1.0.12

1 year ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago