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

hunt-crawler

v1.1.0

Published

a web crawler based on crawlee, use file to cache result. Easy to maintain as Singleton Service.

Downloads

16

Readme

What's this

A http crawler for nodejs. Based on crawlee, puppeteer. Auto handle cache using filesystem Easy to planning your request in queue

How to use

Install

npm i hunt-crawler

Sample

const { Hunter } = require('hunt-crawler')

const $hunter = new Hunter({
  // options for Hunter
  cacheFolder : __dirname + '/../caches'   // where to save cache files
  log : false // show logs
},{
  // options for PuppeteerCrawler
  keepAlive: false, // should the crawler keep alive after request cleaned
})

/**
 * Crawl the url
 * - Start to crawl the url and cache its content to file
 * - Launch browser if not launched
 */
await $hunter.run(
  'https://111.com/somepage', // url to scrawl

  /**
   * Callback
   * handle the content( already cached to file )
   * or start new requests ( $hunter.run )
   */
  async( url, content ){
    console.log( content )
  },

  /**
   * Option
   */
  {
    /** 
     * suffix
     * optional, default '.cache'
     * - the cache file name = md5(url).suffix
     * - $hunter.run prefer to use cache (if exists), except when force=true
     * - You can use this to manage the caches of this page
     */
    suffix :moment.utc().format('YYYY_MM_DD')+'.html',

    /**
     * removeTags
     * optional, default []
     * remove tags from the returned page.content() when save to cache
     */
    removeTags : ['script','svg'],

    /** 
     * play
     * Do actions like scroll, wait or anyting on page in browse.
     */
    async play( url, ctx, $hunter ){
      await new Promise( r => setTimeout(r,200) ) // wait for 1 second
    },

  }
)

More Sample and Test

see /test folder

you could test by run:

node test/simpleCrawl {url?} {force?} node test/batchCrawl {url1} {url2} {url3} ...