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

crawler4nodejs

v1.1.5

Published

Crawler4nodejs is an open source web crawler for Node.js which provides a simple interface for crawling the Web.

Readme

Crawler4nodejs

Crawler4nodejs is an open source web crawler for Node.js which provides a simple interface for crawling the Web.

Table of content

Installation

npm install crawler4nodejs

RUN

Update scripts in package.json

  "scripts": {
    "start": "node -r esm index.js"
  }

Run

npm install

Quickstart

You need to create a crawler class that extends Crawler. This class can override the _process_data() function.

Example

import Crawler from "crawler4nodejs"
const Cheerio = require('cheerio')

export default class ACrawler extends Crawler{

    _process_data(url,html){
        if (html && url){
            const $ = Cheerio.load(html)
            this.fs.appendFileSync("url.txt", url +"\n" , () => { })
            let title = $(this.config.data_selector.title).text();
            if (title)
                this.fs.appendFileSync("test.txt", url + "\n" + title+ "\n",()=>{})
        }
    }
    // process error url
    _store_err_url(url){
        this.fs.appendFileSync("error.txt", url + "\n", () => { })
    }

}
let tuoi_tre_config = {
  name: 'thanhnien_vn',
  origin_url: 'https://thanhnien.vn',
  should_visit_prefix: [ 'https://thanhnien.vn' ],
  page_data_prefix: [ 'https://thanhnien.vn' ],
  should_visit_pattern: '',
  page_data_pattern: '',
  max_depth: '0',
  time_delay: '0',
  content_selector: [
    { name: 'title', selector: '#storybox > h1' },
    {
      name: 'title',
      selector: '#chapeau > div,.l-content .details__content'
    }
  ],
  proxyl: { host: '', port: '0', auth: { username: '', password: '' } }
};

let crawler = new ACrawler(tuoi_tre_config);
crawler.start();

Crawl depth

By default there is no limit on the depth of crawling. But you can limit the depth of crawling. For example, assume that you have a seed page "A", which links to "B", which links to "C", which links to "D". So, we have the following link structure:

A -> B -> C -> D

Since, "A" is a seed page, it will have a depth of 0. "B" will have depth of 1 and so on. You can set a limit on the depth of pages that crawler4j crawls. For example, if you set this limit to 2, it won't crawl page "D". To set the maximum depth you can use:

let config = {
    ...
    max_depth:3
};
let crawler = new ACrawler(config, logger);

License

Copyright (c) 2019 HongLM