HTML Minifier

HTMLMinfier: object;

What's This?

The HTMLMinifier option is a tool within the Scraper API that optimizes webpages by removing unnecessary characters and spaces. Think of it as a way to compress a webpage without losing its core information or functionality. This trimmed version is not only lighter but also faster to process.

Properties

  • useMinifier: Tell the scraper if you want to use the minification tool. By default, it's turned off (false).

  • options:(Optional)  Specific trimming instructions. For instance, you can ask it to remove all the comments or unnecessary spaces from the webpage. By default, no specific instructions are given (null).

  • If you're curious about all the ways you can minify, you can check out more details here.

How Does it Work?

  • Default: { useMinifier:false, options:null } –The webpage is fetched in its original form, without any modifications.

  • Example: By setting HTMLMinifier= {useMinifier: true, options: {collapseWhitespace: true} }, the scraper will eliminate all the redundant spaces from the webpage content.

When Should I Use This?

Consider using the HTMLMinifier option when you prioritize efficiency. It's particularly useful if you're scraping large websites or aiming to save on bandwidth and storage. The compacted content ensures faster downloads and reduced data usage, streamlining your scraping tasks.

Methods

useHTMLMinifier(boolean, object?) 

Configuration Name: HTMLMinfier

Initializing Scraper

const GeonodeScraperApi = require('geonode-scraper-api');
const scraper = new GeonodeScraperApi('<Your_username>', '<Your_password>');

Using Method

const minifierOptions = { caseSensitive: true };
scraper.useHTMLMinifier(true, minifierOptions);
scraper.scrape('https://example.com/');

Using Configuration Object

const minifierOptions = { caseSensitive: true };
const config = { HTMLMinifier: { useMinifier: true, options: minifierOptions } };
scraper.scrape('https://example.com/', config);