Socket
Socket
Sign inDemoInstall

microdata-node

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

microdata-node


Version published
Weekly downloads
4K
decreased by-16.93%
Maintainers
1
Install size
12.9 kB
Created
Weekly downloads
 

Readme

Source

microdata-node Build Status

Cheerio based microdata parser

Example:

var cheerio = require('cheerio');
var microdata = require('microdata-node');

var $ = cheerio.load(
  '<section itemscope itemtype="http://schema.org/Person"> ' +
  '  Hello, my name is ' +
  '  <span itemprop="name">John Doe</span>, ' +
  '  I am a ' +
  '  <span itemprop="jobTitle">graduate research assistant</span> ' +
  '  at the ' +
  '  <span itemprop="affiliation">University of Dreams</span>. ' +
  '  My friends call me ' +
  '  <span itemprop="additionalName">Johnny</span>. ' +
  '  You can visit my homepage at ' +
  '  <a href="http://www.JohnnyD.com" itemprop="url">www.JohnnyD.com</a>. ' +
  '  <section itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">' +
  '    I live at ' +
  '    <span itemprop="streetAddress">1234 Peach Drive</span>,' +
  '    <span itemprop="addressLocality">Warner Robins</span>,' +
  '    <span itemprop="addressRegion">Georgia</span>.' +
  '  </section>' +
  '</section>'
);

var result = microdata.parse($, {
  base: 'http://www.example.com'
});
console.log(JSON.stringify(result, null, 2));

Output:

{
  "items": [
    {
      "type": [ "http://schema.org/Person" ],
      "properties": {
        "name": [ "John Doe" ],
        "jobTitle": [ "graduate research assistant" ],
        "affiliation": [ "University of Dreams" ],
        "additionalName": [ "Johnny" ],
        "url": [ "http://www.johnnyd.com/" ],
        "address": [
          {
            "type": [ "http://schema.org/PostalAddress" ],
            "properties": {
              "streetAddress": [ "1234 Peach Drive" ],
              "addressLocality": [ "Warner Robins" ],
              "addressRegion": [ "Georgia" ]
            }
          }
        ]
      }
    }
  ]
}

API

microdata.parse($, [config])

parses the provided cheerio object with optional configuration.

config.base: base url to resolve url properties against.

Keywords

FAQs

Last updated on 18 Dec 2014

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc