Quick start
polite-crawler needs Node.js 22.19 or later. It operates on Linux, macOS and Windows.
From the command line
Section titled “From the command line”-
Fetch a page. The crawler reads robots.txt first, and then it keeps the page in
~/.polite-crawler.Fetch a page npx polite-crawler fetch https://en.wikipedia.org/wiki/Web_crawler -
Search the store. This step sends no request.
Search the store npx polite-crawler find "robots exclusion" -
Read a part of the page, with the id from the search.
Read a part of a page npx polite-crawler read "url:https://en.wikipedia.org/wiki/Web_crawler" --length 2000 -
Check a quote. The result gives the exact span and the capture to cite.
Check a quote npx polite-crawler verify "url:https://en.wikipedia.org/wiki/Web_crawler" "robots.txt protocol"
Fetch the page again within 24 hours, and the answer comes from the store with no request. Use --max-age 7d to accept an older copy, or --max-age 0 to ask the site again.
From your code
Section titled “From your code”npm install polite-crawlerimport { openCrawler } from "polite-crawler";
const crawler = openCrawler({ dir: "./crawl", // the capture log, the bodies and the index contact: "ops@example.com", // optional: sent in the From header});
const page = await crawler.fetch("https://example.com/", { maxAge: "24h" });console.log(page.outcome, page.status, page.title, page.structured);
for (const hit of await crawler.find("documentation examples")) { console.log(hit.doc, hit.score, hit.snippet);}
const read = await crawler.read(page.doc!, { from: 0, length: 2000 });const check = await crawler.verify(page.doc!, "for use in documentation examples");console.log(check.found, check.capture, check.fetched_at); // the capture to cite
await crawler.close();Each fetch gives the outcome (ok, not-modified, skipped and others), the HTTP status, the document id and the schema.org types of the JSON-LD. It also gives the capture ids, the fetch time and from_cache. When the crawler does not fetch a page, the note tells why, for example robots.txt disallows it for PoliteCrawler.
Pages that need JavaScript
Section titled “Pages that need JavaScript”Some pages show nothing until their scripts run. For these pages, install the optional browser:
npm install playwright-corenpx playwright-core install chromium-headless-shellThe crawler opens the browser only for a page that shows almost nothing without JavaScript. Without the browser, the crawler reads each page as plain HTML. Read the rules.
- Use it from Claude: give an AI assistant the nine tools of the MCP server.
- How it works: the path of each request.
- Search by meaning:
embedandfind --rank hybridwith a local model. - Read hours and prices:
venueandproduct, and a recipe of your own. - Watch pages: the daemon checks a watch list on a schedule.
- The API: each option and each method.