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 🙏

© 2025 – Pkg Stats / Ryan Hefner

scrapino

v1.0.5

Published

Simple but solid node-based web crawler, includes a content extractor

Downloads

17

Readme

Run

Fetch content

Starts crawling from an entry point and calls handlers whenever a page has been fetched. Example:

import { Crawler } from 'scrapino';

const baseUrl = 'https://www.vsao-bern.ch';
const crawler = new Crawler({
  entryPointURL: baseUrl,
  guardrail: [baseUrl, 'https://www.vsao.ch'],
  handleDocument: ({ content, url, mimeType }: HandleSuccessParams): void => {
    console.log('Got content %s with mime type %s for URL %s', content, mimeType, url);
  },
  handleError: (error: Error): void => {
    console.error('Failed: %o', error);
  },
});
crawler.crawl();

The Crawler class takes the following constructor arguments:

  • entryPointURL: string: URL to start crawling from
  • guardrail?: string[]: Array of URLs that limit the scope of crawling. If not specified, defaults to entryPointURL. Needed to make sure you don't crawl the whole internet.
  • handleDocument?: (params: { content: string, url: string, mimeType: string }) => void: Callback that gets called whenever a document has been fetched successfully
  • handleError?: (error: Error) => void: Callback that gets called whenever an error occurs
  • maxAmountOfParallelJobs?: number: Maximum amount of parallel requests, defaults to 1
  • crawlInterval: number: Interval between requests in milliseconds, defaults to 1000; if your site goes down, increase it (or fix your site).
  • logFunction?: (message: string) => void: Log function; defaults to console.log; just pass () => {} if you want to avoid logs.

Extract content

The use of Crawler returns raw HTML. Not the nicest format to read (nor to save it in a vector data base in case you're building a chatbot). There's a helper function that converts your HTML to Markdown and guesses the date when the content was created.

It depends on two external services: ChatGPT and Jina; in order to use them (and this function), you must provide their API Keys.

import { extractContent } from 'scrapino';

const jinaAPIKey = '…';
const openAIAPIKey = '…';

const content = await extractContent({
  content: '<html>…</html>',
  jinaAPIKey,
  openAIAPIKey,
  mimeType: 'text/html',
  url: 'https://www.vsao-bern.ch/news/2022/05/05/review-2011-to-2021',
});

Parameters

The extractContent function takes the following parameters:

  • content: string: Original content that should be converted to Markdown; either HTML text or PDF content (Buffer)
  • jinaAPIKey: string: Well, the Jina API Key
  • openAIAPIKey: string: Your OpenAI API Key
  • mimeType: 'text/html' | 'application/pdf': Your MIME type; only the HTML and PDF are supported
  • url: The URL where your content originated from

Return value

The extractContent function returns a Promise that resolves:

{
  url: string;
  originalContent: string;
  markdownContent: string;
  date: string | null;
}

Test

npm test

Publish

npx tsc before you npm publish.

Some Features

  • Quite forgiving
  • Streams output (the handler is called whenever data becomes available)
  • Provides a way to extract the relevant content from the pages fetched
  • Typescript