struda

Parse structured data from a HTML DOM

Usage no npm install needed!

<script type="module">
  import struda from 'https://cdn.skypack.dev/struda';
</script>

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);