open-graph
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/open-graph package

0.2.6 • Public • Published

Open Graph for Node.js

An Open Graph implementation for Node.js. Simple to use; give it a URL and it'll give you the open graph meta properties scraped from that URL.

Install

npm install open-graph

Usage

const og = require('open-graph');

const url = 'http://github.com/samholmes/node-open-graph/raw/master/test.html';

og(url, function (err, meta) {
  console.log(meta);
});

Outputs:

{
  title: 'OG Testing',
  type: 'website',
  url: 'http://github.com/samholmes/node-open-graph/raw/master/test.html',
  site_name: 'irrelavent',
  description: 'This is a test bed for Open Graph protocol.',
  image: {
    url: 'http://google.com/images/logo.gif',
    width: '100',
    height: '100'
  }
}

Todo

  1. Better parser Meta data should be parsed into pure JSON and arrays should be handled at root nodes, not leaf nodes
  2. Better data types Convert properties to numbers, etc.
  3. Fallback data If Open Graph data isn't present, scrap img elements and document titles off the page.

Package Sidebar

Install

npm i open-graph

Weekly Downloads

2,238

Version

0.2.6

License

BSD

Unpacked Size

6.71 kB

Total Files

5

Last publish

Collaborators

  • samholmes