Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including web-auto-extractor with all npm packages installed. Try it out:

var WAE = require('web-auto-extractor').default //ES6: import WAE from 'web-auto-extractor' var request = require('request') var pageUrl = '' //var pageUrl = '' request(pageUrl, function (error, response, body) { var wae = WAE() var parsed = wae.parse(body) console.log(parsed) })

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

web-auto-extractor v1.0.17

Automatically extracts structured information from webpages

Web Auto Extractor

Build Status

Parse semantically structured information from any HTML webpage.

Supported formats:-

  • Encodings that support vocabularies:-
    • Microdata
    • RDFa-lite
    • JSON-LD
  • Random Meta tags

Popularly, many websites mark up their webpages with vocabularies for better SEO. This library helps you parse that information to JSON.

Demo it on tonicdev


npm install web-auto-extractor


// IF CommonJS
var WAE = require('web-auto-extractor').default
// IF ES6
import WAE from 'web-auto-extractor'

var parsed = WAE().parse(sampleHTML)

Let's use the following text as the sampleHTML in our example. It uses vocabularies to structure a Product information and is encoded in microdata format.


<div itemscope itemtype="">
  <span itemprop="brand">ACME</span>
  <span itemprop="name">Executive Anvil</span>
  <img itemprop="image" src="anvil_executive.jpg" alt="Executive Anvil logo" />
  <span itemprop="description">Sleeker than ACME's Classic Anvil, the
    Executive Anvil is perfect for the business traveler
    looking for something to drop from a height.
  Product #: <span itemprop="mpn">925872</span>
  <span itemprop="aggregateRating" itemscope itemtype="">
    <span itemprop="ratingValue">4.4</span> stars, based on <span itemprop="reviewCount">89
      </span> reviews

  <span itemprop="offers" itemscope itemtype="">
    Regular price: $179.99
    <meta itemprop="priceCurrency" content="USD" />
    lt;span itemprop="price">119.99</span>
    (Sale ends <time itemprop="priceValidUntil" datetime="2020-11-05">
      5 November!</time>)
    Available from: <span itemprop="seller" itemscope itemtype="">
                      <span itemprop="name">Executive Objects</span>
    Condition: <link itemprop="itemCondition" href=""/>Previously owned,
      in excellent condition
    <link itemprop="availability" href=""/>In stock! Order now!</span>


Our parsed object should look like -

  "microdata": {
    "Product": [
        "@context": "",
        "@type": "Product",
        "brand": "ACME",
        "name": "Executive Anvil",
        "image": "anvil_executive.jpg",
        "description": "Sleeker than ACME's Classic Anvil, the\n    Executive Anvil is perfect for the business traveler\n    looking for something to drop from a height.",
        "mpn": "925872",
        "aggregateRating": {
          "@context": "",
          "@type": "AggregateRating",
          "ratingValue": "4.4",
          "reviewCount": "89"
        "offers": {
          "@context": "",
          "@type": "Offer",
          "priceCurrency": "USD",
          "price": "119.99",
          "priceValidUntil": "5 November!",
          "seller": {
            "@context": "",
            "@type": "Organization",
            "name": "Executive Objects"
          "itemCondition": "",
          "availability": ""
  "rdfa": {},
  "jsonld": {},
  "metatags": {
    "priceCurrency": [

The parsed object includes four objects - microdata, rdfa, jsonld and metatags. Since the above HTML does not have any information encoded in rdfa and jsonld, those two objects are empty.


I wouldn't call it a caveat but rather the parser is strict by design. It might not parse like expected if the HTML isn't encoded correctly, so one might assume the parser is broken.

For example, take the following HTML snippet.

<div itemscope itemtype="">
  <h1 itemprop="name">Ghostbusters</h1>
  <div itemprop="productionCompany" itemscope itemtype="">Black Rhino</div>
  <div itemprop="countryOfOrigin" itemscope itemtype="">
    Country: <span itemprop="name" content="USA">United States</span><p>

The problem here is the itemprop - productionCompany which is of itemtype - Organization doesn't have any itemprop as its children, in this case - name.

The parser assumes every itemtype contains an itemprop, or every typeof contains a property in case of rdfa. So the "Black Rhino" information is lost.

It'll be nice to fix this by having a non-strict mode for parsing this information. PRs are welcome.




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free