html-scrapper-ts
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

A small tool to scrap HTML using Typescript!

Installation

npm i --save-dev html-scrapper-ts

Access all elements by type

import { HTMLParser } from 'html-scrapper-ts';
const file = readFileSync('dir/my-file-path.html');
const html = new HTML(file.toString());
const h1Elements = html.elements['H1'];

Access document functions

import { HTMLParser } from 'html-scrapper-ts';
const file = readFileSync('dir/my-file-path.html');
const html = new HTML(file.toString());
const elements = html.document.querySelector('tr')

getElements

import { HTMLParser } from 'html-scrapper-ts';
const file = readFileSync('dir/my-file-path.html');
const htmlAsString = "<html><body><h1>Title!</h1></body></html>
const html1 = new HTML(file.toString());
const html2 = new HTML(htmlAsString);
//Get all elements data:
const allElements = html1.elements;

//Filter out elements by tag
const listOfH1 = html1.getElements('h1');

//Filter out by elements and their properties
const listOfH1WithClass = html2.getElements('h1', [{
    name: 'class',
    value: 'my-special-class'
}])

Readme

Keywords

none

Package Sidebar

Install

npm i html-scrapper-ts

Weekly Downloads

1,635

Version

0.2.1

License

Apache 2.0

Unpacked Size

19.1 kB

Total Files

10

Last publish

Collaborators

  • danitseitlin