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 🙏

© 2026 – Pkg Stats / Ryan Hefner

scraperama

v2.0.0

Published

Scrape csv, json, html and xml files

Readme

scraperama

Scrape files from the internet. Async, ESM, zero-HTTP-dependency (uses native fetch).

Installation

npm i scraperama

Requires Node 18+ (for native fetch).

Usage

import * as scraperama from "scraperama";

Fetch and parse

const $ = await html("https://example.com");
$("h1").text(); // Cheerio instance

const rows = await csv("https://example.com/data.csv");
// Array of objects parsed by d3-dsv

const obj = await json("https://example.com/data.json");
// Parsed JSON

const str = await text("https://example.com/file.txt");
// Raw text string

const $ = await xml("https://example.com/sitemap.xml");
$("loc").each((_, el) => console.log($(el).text()));
// Cheerio instance in XML mode

Headless browser

Fetch pages with a headless Chromium browser (via Playwright). Useful for JS-rendered pages or sites behind WAF challenges.

npm i playwright

Pass { browser: true } for one-off requests — a browser is launched and closed automatically each time:

const $ = await html("https://www.epa.gov/newsreleases/search", {
  browser: true,
});

For bulk scraping, create a reusable browser instance with createBrowser() and pass it via the browser option. Pages are opened and closed per request, but the browser stays alive:

const browser = await createBrowser();

const $ = await html("https://example.com", { browser });

await browser.close();

Works with html, xml, csv, json, and text. When browser is not set, native fetch is used as before.

Retries

Automatically retry failed requests (non-2xx responses or network errors) with exponential backoff:

const $ = await html("https://example.com", {
  retries: 3,
  retryDelay: 1000,
});
  • retries — number of retry attempts after the initial failure (default 0)
  • retryDelay — base delay in milliseconds (default 1000). Each subsequent retry doubles the delay (1s, 2s, 4s, …).

Works with html, xml, csv, json, and text, and can be combined with the browser option.

Download a file

await download("https://example.com/file.zip", "./file.zip", (pct) =>
  process.stdout.write(`\r${pct.toFixed(1)}%`),
);

Extract archives

await untar("./file.tar", "./output");
await unzip("./file.zip", "./output");

Throttle

Wrap any function with throttle(fn, rate) to limit how often it runs. Calls are queued and executed at most once every rate milliseconds:

const log = throttle(console.log, 500);
for (let i = 0; i < 10; i++) log(i); // logs one value every 500ms

This is especially useful for bulk scraping with a headless browser, where you want to avoid overwhelming a server:

import { createBrowser, html, throttle } from "scraperama";

const browser = await createBrowser();
const urls = [
  "https://example.com/page/1",
  "https://example.com/page/2" /* ... */,
];

const scrape = throttle(async (url) => {
  const $ = await html(url, { browser });
  console.log($("h1").text());
}, 1000);

for (const url of urls) {
  scrape(url);
}

// When finished:
await browser.close();

Utilities

datestamp(); // "2026-02-27"
datestamp(new Date(1999, 0, 1)); // "1999-01-01"

filesize(someObject); // "1.2 MB"

Testing

Each module has a corresponding test script in test/. These are integration tests that hit the network (except datestamp and throttle, which are local-only).

Run any individual test with:

node test/html-test.js
node test/csv-test.js
node test/download-test.js
# etc.

Run all tests:

npm test

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

License

MIT