A small Node.js web crawler that starts from a list of ~1,000,000 seed URLs (seed.json), stores the frontier in Redis, and keeps crawling by respawning a worker process that pulls a random batch of URLs, fetches them, extracts outbound links, and feeds them back into the seed set.
- index.js loads
seed.jsoninto a Redis set (seeds), then spawns crawler.js as a child process and respawns it every time it exits, so the crawl continues indefinitely. - crawler.js pulls a random batch of URLs out of the
seedsset, crawls them withcrawler, parses each page with Cheerio, and adds every absolutehttp(s)link it finds back intoseeds. Once it has crawledPAGES_PER_RUNpages it exits cleanly, which triggers the next respawn fromindex.js. - lib/ holds the small, dependency-light pieces of logic (config, seed-file parsing, link extraction) that are covered by unit tests in test/; test/integration/ covers the crawl loop end-to-end against a real Redis instance.
- Node.js 22 or later (see .nvmrc /
package.json
engines) - A running Redis server (v5+ recommended)
npm installConfiguration is read from environment variables (see .env.example for the full list and defaults):
cp .env.example .env
# edit .env if you need to point at a non-default Redis instance, etc.npm start
# or, to load .env automatically:
node --env-file=.env index.jsThis seeds Redis from seed.json and starts the crawl loop. Stop it with
Ctrl+C.
| Variable | Default | Description |
|---|---|---|
REDIS_URL |
redis://127.0.0.1:6379 |
Redis connection string |
SEED_FILE |
./seed.json |
Path to the seed URL JSON file |
SEEDS_KEY |
seeds |
Redis set used to store the crawl frontier |
PAGES_PER_RUN |
1000 |
Pages crawled per crawler.js run before exit |
MAX_CONNECTIONS |
100 |
Max concurrent HTTP connections while crawling |
npm test # run the unit test suite (node:test, no external deps)
npm run test:integration # run crawler.js end-to-end against a real Redis instance
npm run test:coverage # unit tests with Node's built-in coverage report
npm run lint # lint with ESLint
npm run format # format with Prettiernpm run test:integration requires a reachable Redis (it uses REDIS_URL,
same as the app) and spins up a throwaway local HTTP server as the crawl
target — it doesn't hit the network. It writes to a randomly-named Redis set
(via SEEDS_KEY) and deletes it afterwards, so it's safe to run against a
Redis instance you're also using for local development. If Redis isn't
reachable, the test is skipped rather than failing.
CI (see .github/workflows/ci.yml) runs lint, formatting, unit tests, and the integration test (with a Redis service container) on every push and pull request.
See CONTRIBUTING.md for the full contribution workflow.
- CONTRIBUTING.md — how to propose changes
- CODE_OF_CONDUCT.md — community standards
- SECURITY.md — how to report a vulnerability
- AI_USAGE.md — how AI assistance is used and disclosed in this project
- NOTICE — third-party attributions
- CITATION.cff — how to cite this software
- LICENSE — ISC license