Socket
Socket
Sign inDemoInstall

microdata-node

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

microdata-node - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

3

package.json
{
"name": "microdata-node",
"version": "0.0.2",
"version": "0.0.3",
"description": "Cheerio based microdata parser",

@@ -29,2 +29,3 @@ "main": "lib",

"cheerio": "^0.18.0",
"jshint": "^2.5.10",
"jshint-stylish": "^1.0.0",

@@ -31,0 +32,0 @@ "mocha": "^2.0.1"

@@ -8,55 +8,59 @@ microdata-node [![Build Status](https://travis-ci.org/Janpot/microdata-node.svg)](https://travis-ci.org/Janpot/microdata-node)

var cheerio = require('cheerio');
var microdata = require('microdata-node');
```js
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 $ = 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));
var result = microdata.parse($, {
base: 'http://www.example.com'
});
console.log(JSON.stringify(result, null, 2));
```
/* output:
[
{
"type": "http://schema.org/Person",
"id": null,
"props": {
"name": "John Doe",
"jobTitle": "graduate research assistant",
"affiliation": "University of Dreams",
"additionalName": "Johnny",
"url": "http://www.johnnyd.com/",
"address": {
"type": "http://schema.org/PostalAddress",
"id": null,
"props": {
"streetAddress": "1234 Peach Drive",
"addressLocality": "Warner Robins",
"addressRegion": "Georgia"
}
}
}
Output:
```json
[
{
"type": "http://schema.org/Person",
"id": null,
"props": {
"name": "John Doe",
"jobTitle": "graduate research assistant",
"affiliation": "University of Dreams",
"additionalName": "Johnny",
"url": "http://www.johnnyd.com/",
"address": {
"type": "http://schema.org/PostalAddress",
"id": null,
"props": {
"streetAddress": "1234 Peach Drive",
"addressLocality": "Warner Robins",
"addressRegion": "Georgia"
}
]
*/
}
}
}
]
```

@@ -63,0 +67,0 @@ ## API

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc