Parses a webpage for opengraph information with smart fallbacks. Will attempt to get page information even if opengraph information does not exist.
Add it to your project:
npm i https://github.com/yurivictor/better-opengraph.git --save
const bo = require( 'better-opengraph' );
bo( 'https://www.nytimes.com/' )
.then( json => console.log( json ) )
.catch( error => console.log( error ) );
- title {String} – The webpage title
- description {String} – The webpage description
- image {Object}
- url {String} – The image for the page
- site_name {String} – The name of the site
- type {String} – The type of content (default: article)
- url {String} – The canonical url for the page or the requested url
{
"title": "Breaking News, World News & Multimedia",
"description": "The New York Times: Find breaking news, multimedia, reviews & opinion on Washington, business, sports, movies, travel, books, jobs, education, real estate, cars & more at nytimes.com.",
"image": {
"url": "https://static01.nyt.com/newsgraphics/images/icons/defaultPromoCrop.png"
},
"site_name": "@nytimes",
"type": "website",
"url": "https://www.nytimes.com"
}
The original author is @yurivictor.