Socket
Socket
Sign inDemoInstall

@devmehq/open-graph-extractor

Package Overview
Dependencies
15
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @devmehq/open-graph-extractor

Extract Open Graph and Twitter Card info off from html


Version published
Weekly downloads
285
increased by119.23%
Maintainers
1
Install size
2.63 MB
Created
Weekly downloads
 

Changelog

Source

v1.0.4

  • Added fallback itemProp thanks @markwcollins #56
  • Fixed test

Readme

Source

Open Graph Extractor

Build Status NPM version Downloads

A simple tools for scraping Open Graph and Twitter Card info off from html.

API / Cloud Hosted Service

We offer this URL Scrapping & Metadata Service in our Scalable Cloud API Service Offering - You could try it here URL Scrapping & Metadata Service

Self-hosting - installation and usage instructions

Installation

Install the module through YARN:

yarn add @devmehq/open-graph-extractor

Or NPM

npm install @devmehq/open-graph-extractor

Examples

// use your favorite request library, in this example i will use axios to get the html
import axios from "axios";
import { extractOpenGraph } from '@devmehq/open-graph-extractor';
const { data: html } = axios.get('https://ogp.me')
const openGraph = extractOpenGraph(html);

Results JSON

{
  ogTitle: 'Open Graph protocol',
  ogType: 'website',
  ogUrl: 'https://ogp.me/',
  ogDescription: 'The Open Graph protocol enables any web page to become a rich object in a social graph.',
  ogImage: {
    url: 'http://ogp.me/logo.png',
    width: '300',
    height: '300',
    type: 'image/png'
  }
} 

Configuration options

customMetaTags

Here you can define custom meta tags you want to scrape. Default: [].

allMedia

By default, OGS will only send back the first image/video it finds. Default: false.

onlyGetOpenGraphInfo

Only fetch open graph info and don't fall back on anything else. Default: false.

ogImageFallback

Fetch other images if no open graph ones are found. Default: false.

Testing

yarn test

Contributing

Please feel free to open an issue or create a pull request and fix bugs or add features, All contributions are welcome. Thank you!

LICENSE MIT

Keywords

FAQs

Last updated on 25 May 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc