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

scraper-node

v1.0.1

Published

Simple, easy-to-use scraping module for single webpages

Readme

scraper-node

NPM version License NPM downloads downloads per month

Easily scrape any webpage! The scraper-node module will periodically send a request to the URL you provide. Upon receiving a response, the scraper emits an event with the response.

Installation

npm install scraper-node

Example Usage

const Scraper = require('scraper-node');
const scraper = new Scraper('https://www.example.com');

scraper.on('scrape', response => {
	console.log(`${response.status} ${response.statusText}`);
});

scraper.on('error', error => {
	console.error(error.stack);
});

scraper.setPollRate('30m');

The response being emitted from a scrape is a node-fetch response object. You can work with it just as you would a fetch response from node-fetch.

API

Class: Scraper

new Scraper(url[, pollRate])

Construct a new Scraper instance. Arguments:

  • url: The desired URL to scrape
  • pollRate: Optional interval between scrapes. If none is provided, this defaults to 1 hour. This can be provided as a value in milliseconds, however a time string can also be accepted.

Throws a TypeError if pollRate is neither a number nor a time string. Throws a TypeError for invalid URLs. Throws a TypeError if the URL protocol is not either of HTTP or HTTPS.

scraper.url

The URL being scraped. Read-only.

scraper.pollRate

Time between scrapes, as a number in milliseconds. Read-only.

scraper.lastResponse

Response object from the last successful scrape. Read-only.

scraper.setURL(url)

Change the URL being scraped. Throws a TypeError for invalid URLs. Throws a TypeError if the URL protocol is not either of HTTP or HTTPS.

scraper.setPollRate(pollRate)

Change the time interval between scrapes. Throws a TypeError if pollRate is neither a number nor a time string.

scraper.stop()

Stop the scraper from scraping the URL.

scraper.resume()

If the scraper has been stopped using scraper.stop(), resume scraping. The next scrape will occur after the duration of the current poll rate. Does nothing if scraping has not been stopped.

Events

  • 'scrape': emited when the target URL returns a response, providing the response as an argument
  • 'error': emited when there an error occurs during the fetch. Note that this is not the same as 4xx and 5xx response codes, which will be returned as standard responses through the scrape event

Time String

A string of the form "1y 1w 1d 1h 1m 1s 1ms". Any time unit may be omitted, however the relative order of terms may not be changed. Spaces between terms are optional.

  • y = years
  • w = weeks
  • d = days
  • h = hours
  • m = minutes
  • s = seconds
  • ms = milliseconds

The string "2h 30m 59s" would represent 2 hours, 30 minutes, and 59 seconds; when converted into milliseconds for the poll rate this is 9059000.

License

Licensed under MIT
Copyright (c) 2021 Walker Gray