Skip to content

HTML parser that works both in JavaScript and NodeJS with TypeScript support

License

Notifications You must be signed in to change notification settings

ilyaGurevich/isomorphic-htmlparser

 
 

Repository files navigation

Isomorphic HTMLParser

CodeQL codecov semantic-release code style: prettier

HTML parser that works both in JavaScript and NodeJS with TypeScript support.

Missing something? Create feature request!

Read Documentation 📘

Check Demo 🎁

Installation

npm version npm

Install with NPM/yarn:

# NPM
npm install isomorphic-htmlparser
# Yarn
yarn add isomorphic-htmlparser

Import what you need:

import { parseHTML } from 'isomorphic-htmlparser'

const el = parseHTML(html).find('.my-class > a.title')
const text = parseHTML(html).extract('.my-class > a.title @ text | trim')

console.log(el.text.trim() === text)
// true

Always import only what is necessary to take full advantage of tree shaking.

Load directly in the browser

Include UMD bundle

Include script from CDN and use isomorphicHtmlparser global variable:

<script src="https://unpkg.com/isomorphic-htmlparser"></script>
<script>
    const { parseHTML } = window.isomorphicHtmlparser

    const el = parseHTML(html).find('.my-class > a.title')
    const text = parseHTML(html).extract('.my-class > a.title @ text | trim')

    console.log(el.text.trim() === text)
    // true
</script>

About

HTML parser that works both in JavaScript and NodeJS with TypeScript support

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%