Socket
Socket
Sign inDemoInstall

og-metadata

Package Overview
Dependencies
145
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    og-metadata

Npm package for web scraping purposes. You give it an URL, and it lets you easily get its title, links, images, description, keywords, meta tags


Version published
Weekly downloads
12
increased by1100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

status

og-metadata

An npm package to access website metadata & link tags. Returns the title, description, favicon, preview image, keywords, theme color, etc. for a given website url.

Install

With npm:

npm install og-metadata

With yarn:

yarn add og-metadata

Example

Add og-metadata to a Nodejs project & access like

// example export as a Firebase Function
exports.getUrlMetadata = functions.https.onCall((data, context) => {
  const url = data.url; // eg. https://tylerj.me
  if (url) {
    // begin og-metadata code
    const MetaInspector = require("og-metadata");

    var client = new MetaInspector(url, { timeout: 5000 });
    return client.fetch().then(() => {
      // note: no error handling yet
      const data = {
        title: client.title,
        description: client.description,
        image: client.image,
        favicon: client.favicon,
        appleTouchIcon: client.appleTouchIcon,
        url: client.url,
        host: client.host,
        keywords: client.keywords,
        themeColor: client.themeColor,
        twitterCreator: client.twitterCreator,
      };
      return data;
    });
  }
});

Available data

KeyDescription
urlfull url of the page
schemescheme of the page (http, https)
hosthostname of the page (eg. tylerj.me)
rootUrlabsolute url of the page w/o subpages or queries
titletitle of the page
descriptiondescription of the page or the first long paragraph if no meta description is provided
authorpage author
keywordspage keywords, as an array
charsetcharset of the page
linksevery link found on the page, as an array
themeColortheme color of the page, if provided
imagesocial preview image of the page
faviconwebsite favicon image
appleTouchIconApple touch icon of the page, if provided
imagesevery image found on the page, as an array
feedsrss or atom links, as an array
ogTitleopengraph title
ogDescriptionopengraph description
ogTypeopengraph object type
ogUpdatedTimeopengraph updated time
ogLocaleopengraph locale language
ogImageAltopengraph image alt text
twitterCreatorTwitter creator, if provided

Options

OptionDescriptionDefault value
timeoutthe time in ms to wait for the url to respond20000ms
maxRedirectsthe number of redirects allowed5
strictSSLforce SSL (https instead of http)false
headersoptions headers for the request{ 'User-Agent' : 'MetaInspector/1.0' }

FAQs

Last updated on 27 Oct 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