šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

meta-og-scrape

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meta-og-scrape

Scrape meta, link & open graph tags from the head of document as a JavaScript object (JSON)

1.0.0
latest
Source
npm
Version published
Weekly downloads
357
-0.56%
Maintainers
1
Weekly downloads
Ā 
Created
Source

meta-og-scrape

meta-og-scrape, (built from OpenGraphJS) builds a JSON object from a web page which follows the Open Graph Protocol. The JavaScript object returned by this library contains important metadata such as the description, image, and title.

Code Climate Build Status Test Coverage npm

Installation

npm install meta-og-scrape

Usage

Promise support

  • Its easy, if you are using a version of node with Promises you are ready to go!
  • Other versions of node:
    • define global.Promise = require('bluebird');
    • Feel free to substitute Bluebird with your perferred promise library
// Include it
var ogjs = require('meta-og-scrape');
// Pass in a URL
ogjs({ url: 'http://animateme.app' })
  .then(function (data) {
    console.log(data); // some share data parsed from metatags..
  }, function (err) {
    console.log('It seems that we have fumbled with an error', err);
  });

Callbacks

// Include it
var ogjs = require('meta-og-scrape');
// Pass in a URL
ogjs({ url: 'http://animateme.app' }, function (err, data) {
    if (err) {
      console.log('It seems that we have fumbled with an error', err);
      return;
    }
    
    console.log(data); // some share data parsed from metatags..
  });

Expected ouput

Sample

{ 
  title: 'Open Graph protocol',
  type: 'website',
  url: 'http://ogp.me/',
  description: 'The Open Graph protocol enables any web page to become a rich object in a social graph.',
  image: [{ 
    url: 'http://ogp.me/logo.png',
    type: 'image/png',
    width: '300',
    height: '300' 
  }]
}

Supported properties

Property NameJS NameTypeDescription
og:titletitlestringtitle set in og:title, if missing uses the page's title tag
og:typetypestringopen graph type for the current document
og:urlurlstringsharable url to content
og:descriptiondescriptionstringdescribes the media/page being shared
og:determinerdeterminerstring
og:localelocaleobjecthas two properties, `name` which contains the default locale
and `alternate` which is an array of strings with additional locales
og:site_namesiteNamestring
og:imageimagearrayArray of objects

Properties:
- url (always present)
- secureUrl (optional)
- width (optional)
- height (optional)
og:videovideoarrayArray of objects

Properties:
- url (always present)
- secureUrl (optional)
- width (optional)
- height (optional)
og:audioaudioarrayArray of objects

Properties:
- url (always present)
- secureUrl (optional)

Credits and Acknowledgements

Keywords

open graph

FAQs

Package last updated on 16 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts