Socket
Book a DemoInstallSign in
Socket

html-scrapper-ts

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-scrapper-ts

A HTML scrapping tool written in Typescript

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
389
-46.49%
Maintainers
1
Weekly downloads
 
Created
Source

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'
}])

FAQs

Package last updated on 14 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts