npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-get

v2.16.9

Published

Get the HTML from any website, fine-tuned for correction & speed

Downloads

2,915

Readme

Last version Coverage Status NPM Status

Get the HTML from any website, fine-tuned for correction & speed.

Features

  • Get HTML markup for any URL, including images, video, audio, or pdf.
  • Block ads tracker or any non-necessary network subrequest.
  • Handle unreachable or timeout URLs gracefully.
  • Ensure HTML markup is appropriately encoded.

html-get takes advantage of puppeteer headless technology when is needed, such as client-side apps that needs to be prerender.

Install

$ npm install browserless puppeteer html-get --save

Usage

const createBrowserless = require('browserless')
const getHTML = require('html-get')

// Spawn Chromium process once
const browserlessFactory = createBrowserless()

// Kill the process when Node.js exit
process.on('exit', () => {
  console.log('closing resources!')
  browserlessFactory.close()
})

const getContent = async url => {
  // create a browser context inside Chromium process
  const browserContext = browserlessFactory.createContext()
  const getBrowserless = () => browserContext
  const result = await getHTML(url, { getBrowserless })
  // close the browser context after it's used
  await getBrowserless((browser) => browser.destroyContext())
  return result
}

getContent('https://example.com')
  .then(content => {
    console.log(content)
    process.exit()
  })
  .catch(error => {
    console.error(error)
    process.exit(1)
  })

Command Line

$ npx html-get https://example.com

API

getHTML(url, [options])

url

Required Type: string

The target URL for getting the HTML markup.

options

encoding

Type: string Default: 'utf-8'

It ensures the HTML markup is encoded to the encoded value provided.

The value will be passes to html-encode

getBrowserless

Required Type: function

A function that should return a browserless instance to be used for interact with puppeteer:

getMode

Type: function

It determines the strategy to use based on the url, being the possibles values 'fetch' or 'prerender' .

getTemporalFile

Type: function

It creates a temporal file.

gotOpts

Type: object

It passes configuration object to got under 'fetch' strategy.

headers

Type: object

Request headers that will be passed to fetch/prerender process.

mutoolPath

Type: function

It returns the path for mutool binary, used for turning PDF files into HTML markup.

prerender

Type: boolean|string Default: 'auto'

Enable or disable prerendering as mechanism for getting the HTML markup explicitly.

The value auto means that that internally use a list of websites that don't need to use prerendering by default. This list is used for speedup the process, using fetch mode for these websites.

See getMode parameter for know more.

puppeteerOpts

Type: object

It passes coniguration object to puppeteer under 'prerender' strategy.

rewriteUrls

Type: boolean Default: false

When is true, it will be rewritten CSS/HTML relatives URLs present in the HTML markup into absolutes.

License

html-get © Microlink, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.

microlink.io · GitHub microlinkhq · X @microlinkhq