microdata-node
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"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" |
102
README.md
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73
9173
5