beau6183 / ts-open-graph-scraper

Node.js scraper module for Open Graph and Twitter Card info, based on https://github.com/jshemas/openGraphScraper
MIT License
0 stars 0 forks source link

ts-open-graph-scraper

Build Status Known Vulnerabilities Coverage Status

A simple typescript-based node module for scraping Open Graph and Twitter Card info off a site.

Installation

npm install ts-open-graph-scraper

Usage

The major departure from @jshemas's openGraphScraper is this is entirely Typescript-based and implements only a promise interface. Additionally, it uses request-promise-native internally, so overloading it with Bluebird, etc., requires hoisting.

The OGOptions parameter extends Request's URL-based options, with the exclusion of json and callback options. Any other parameter is forwarded on. (eg, if you want to override headers, user-agent, etc., you can do it through these options where possible in request)

Additional properties are mostly similar to what's found in @jshemas's openGraphScraper

import ogs from 'ts-open-graph-scraper'

async function main() {
  const ogResults = await ogs('https://opg.me')
  // OR
  const ogResults = await ogs({
    url: 'https://opg.me'
  })
  console.table(ogResults)
}

To-Dos

Contributing

I'll do my best to keep this maintained. In general: