struda
v0.3.0
Published
Parse structured data from a HTML DOM
Downloads
9
Readme
struda
Structured data extraction from HTML.
import { parse } from 'struda';
const result = parse(window.document);
// {
// "jsonld": {
// "data": [ ... ],
// "errors": []
// },
// "microformats": {
// "data": {
// "items": [ ... ],
// "rels": { ... },
// "rel-urls": { ... }
// },
// "errors": []
// }
// }
Installation
npm install --save struda
Features
- Performance: the data is parsed in a single traversal of the DOM
- Parses jsonld and microformats (rdfa and microdata are planned)
Example
Use jsdom
outside of the browser:
import { JSDOM } from 'jsdom';
import { parse } from 'struda';
const window = new JSDOM(`...`, { url: 'https://example.com/' })
const result = parse(window.document);