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

@ta11y/extract

v1.3.1

Published

Extracts content from websites for running accessibility audits with ta11y.

Downloads

28

Readme

@ta11y/extract

Extracts content from websites for running accessibility audits with ta11y.

NPM Build Status JavaScript Style Guide

Install

npm install --save @ta11y/extract

Usage

The easiest way to use this package is to use the CLI.

const { extract } = require('@ta11y/extract')

extract('https://en.wikipedia.org')
  .then((result) => {
    console.log(result.summary) // overview of results (number of urls visited, success, error)
    console.log(result.results) // detailed results keyed by url
  })
const { extract } = require('@ta11y/extract')

// example passing HTML directly
extract('<!doctype><html><body><h1>I ❤ accessibility</h1></body></html>')
  .then((result) => {
    console.log(result.summary) // overview of results (number of urls visited, success, error)
    console.log(result.results) // detailed results keyed by url

    // note that the result key for an HTML input is 'root' instead of url
  })

API

extract

Extracts the dynamic HTML content from a website, optionally crawling the site to discover additional pages and extracting those too.

Type: function (urlOrHtml, opts): Promise

  • urlOrHtml string URL or raw HTML to process.
  • opts object Config options.
    • opts.browser object Required Puppeteer browser instance to use.
    • opts.crawl boolean Whether or not to crawl additional pages. (optional, default false)
    • opts.maxDepth number Maximum crawl depth while crawling. (optional, default 16)
    • opts.maxVisit number? Maximum number of pages to visit while crawling.
    • opts.sameOrigin boolean Whether or not to only consider crawling links with the same origin as the root URL. (optional, default true)
    • opts.blacklist Array<string>? Optional blacklist of URL glob patterns to ignore.
    • opts.whitelist Array<string>? Optional whitelist of URL glob patterns to only include.
    • opts.gotoOptions object? Customize the Page.goto navigation options.
    • opts.viewport object? Set the browser window's viewport dimensions and/or resolution.
    • opts.userAgent string? Set the browser's user-agent.
    • opts.emulateDevice string? Emulate a specific device type.- Use the name property from one of the built-in devices.
      • Overrides viewport and userAgent.
    • opts.onNewPage function? Optional async function called every time a new page is initialized before proceeding with extraction.

License

MIT © Saasify