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

@a11ywatch/crawler

v0.9.6

Published

gRPC tokio based web crawler

Downloads

689

Readme

crawler

A gRPC web indexer turbo charged for performance.

This project is capable of handling millions of pages per second efficiently.

Getting Started

Make sure to have Rust installed or Docker.

This project requires that you start up another gRPC server on port 50051 following the proto spec.

The user agent is spoofed on each crawl to a random agent and the indexer extends spider as the base.

  1. cargo run or docker compose up

Installation

You can install easily with the following:

Cargo

The crate is available to setup a gRPC server within rust projects.

cargo install website_crawler

Docker

You can use also use the docker image at a11ywatch/crawler.

Set the CRAWLER_IMAGE env var to darwin-arm64 to get the native m1 mac image.

crawler:
  container_name: crawler
  image: "a11ywatch/crawler:${CRAWLER_IMAGE:-latest}"
  ports:
    - 50055

Node / Bun

We also release the package to npm @a11ywatch/crawler.

npm i @a11ywatch/crawler

After import at the top of your project to start the gRPC server or run node directly against the module.

import "@a11ywatch/crawler";

Example

This is a basic example crawling a web page, add spider to your Cargo.toml:

[dependencies]
website_crawler = "0.9.4"

A basic example can also be done with:

One terminal run the server

cargo run --example server --release

Another terminal run the client/server

cargo run --example client --release

https://user-images.githubusercontent.com/8095978/221221122-cfed83aa-6ca1-4122-a1db-0d9948e9f9d9.mov

Dependencies

In order to build crawler locally >= 0.5.0, you need the protoc Protocol Buffers compiler, along with Protocol Buffers resource files.

Ubuntu

proto compiler needs to be at v3 in order to compile. Ubuntu 18+ auto installs.

sudo apt update && sudo apt upgrade -y
sudo apt install -y protobuf-compiler libprotobuf-dev

Alpine Linux

sudo apk add protoc protobuf-dev

macOS

Assuming Homebrew is already installed. (If not, see instructions for installing Homebrew on the Homebrew website.)

brew install protobuf

Features

  1. jemalloc - use jemalloc memory allocator (default disabled).
  2. regex - use the regex crate for blacklist urls validation.
  3. ua_generator - use the ua_generator crate to spoof random user agent.
  4. smart - use smart mode to run HTTP request first and chrome when JS is needed.
  5. chrome: Enables chrome headless rendering, use the env var CHROME_URL to connect remotely.

About

This crawler is optimized for reduced latency and uses isolated based concurrency as it can handle over 10,000 pages within several milliseconds. In order to receive the links found for the crawler you need to add the website.proto to your server. This is required since every request spawns a thread. Isolating the context drastically improves performance (preventing shared resources / communication ).

Help

If you need help implementing the gRPC server to receive the pages or links when found check out the gRPC node example for a starting point .

LICENSE

Check the license file in the root of the project.