GithubHelp home page GithubHelp logo

devmehq / open-graph-extractor Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 1.19 MB

Extract Open Graph and Metadata from html in node.js

Home Page: https://dev.me/products/url-scrapper

License: MIT License

JavaScript 0.44% Shell 0.06% TypeScript 11.74% HTML 87.77%
opengraph extractor opengraph-tags metadata-extractor

open-graph-extractor's Introduction

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

open-graph-extractor's People

Contributors

dependabot[bot] avatar markwcollins avatar meabed avatar renovate-bot avatar renovate[bot] avatar yutkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

open-graph-extractor's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • styfle/cancel-workflow-action 0.12.1
  • actions/checkout v4
  • FranzDiebold/github-env-vars-action v2
  • actions/setup-node v4
.github/workflows/release.yml
  • styfle/cancel-workflow-action 0.12.1
  • actions/checkout v4
  • FranzDiebold/github-env-vars-action v2
  • actions/setup-node v4
npm
package.json
  • cheerio 1.0.0-rc.12
  • @types/chai 4.3.16
  • @types/cheerio 0.22.35
  • @types/jest ^29.5.12
  • @types/node 20.14.2
  • @typescript-eslint/eslint-plugin 7.13.0
  • @typescript-eslint/parser 7.13.0
  • axios 1.7.2
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-prettier 5.1.3
  • eslint-plugin-unused-imports 3.2.0
  • husky 9.0.11
  • jest ^29.7.0
  • lint-staged 15.2.7
  • prettier 3.3.2
  • ts-jest ^29.1.2
  • typescript 5.4.5
  • node >= 12.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.