Command line
npx polite-crawler <command> [options]Commands
Section titled “Commands”| Command | What it does |
|---|---|
fetch <url...> |
It fetches the pages into the store. robots.txt applies. |
find <query> |
It searches the stored pages. It sends no request. |
read <doc> |
It prints a range of a stored document. |
verify <doc> <quote> |
It finds a quote in a stored document. |
extract <doc> - |
It checks the values that you propose for the fields of a stored document. It does not make values. |
reindex |
It builds the search index again from the capture log. |
mcp |
Deprecated: it starts the MCP server of the package polite- on the standard input and output, and 0.3.0 removes it. Without that package, it tells you to start npx polite- and exits with 2. |
export - |
It writes the stored captures as a WARC or WACZ archive. It only reads the store. |
discover <site> |
It lists the pages of a site from its sitemaps and feeds. It fetches no page of the list. |
crawl <url...> |
It fetches the pages and follows their links on the same site, within a budget. |
diff <doc> |
It prints what changed between two versions of a stored document. It sends no request. |
watch add <url...> |
It adds the pages to the watch list, or changes the options of their watch. |
watch remove <url...> |
It removes the pages from the watch list. |
watch list |
It prints the watch list. |
watch run |
It checks the pages that are due, within a budget, and prints what changed. |
daemon |
It checks the watch list on a schedule, until SIGINT or SIGTERM. With --mcp-, it also serves the MCP tools over local HTTP, with the package polite-. |
daemon status |
It prints the state of the daemon of the store. It opens no store. |
key- |
It prints the key directory (a JSON Web Key Set) of --sign-, for you to host. |
embed - |
It gives vectors to the stored pages that have none, for find -. It sends no request to a site. |
venue <url> |
It reads the opening hours of a venue from its own site, with the source of each reading. |
product <url> |
It reads the schema.org Product data of a product page: the name, the codes, the price, the availability and the variant. |
Options
Section titled “Options”These options apply to each command:
| Option | Default | What it does |
|---|---|---|
--dir <path> |
$POLITE_, or ~/ |
The store. A path that starts with ~ is in your home folder, and a relative path starts at the working folder. |
--contact <text> |
$POLITE_ |
An email (in From and the User-) or a URL (in the User- only). |
--allow- |
$POLITE_ |
Fetch loopback, private and link-local addresses too. By default, the crawler refuses them. |
--no- |
Do not open the headless browser. | |
--sign- |
$POLITE_ |
Sign each request (Web Bot Auth) with this Ed25519 key: PKCS#8 PEM or a JWK. It needs --signature-. fetch, discover, crawl, watch run, mcp, key-, venue and product take it. |
--signature- |
$POLITE_ |
Where a site finds the public key: the https origin of the key directory, or the URL of a JSON Web Key Set on a path. |
--json |
Print JSON. | |
-v, --version |
Print the version and stop. | |
-h, --help |
Print the commands and the options, and stop. |
These options apply to one command. The command line is wrong when another command gets them.
| Command | Option | Default | What it does |
|---|---|---|---|
fetch, crawl, watch add, venue, product |
--render <mode> |
auto |
auto, never or always. |
fetch, crawl, discover, venue, product |
--max- |
24h |
A stored copy younger than this age answers with no request. 0 fetches the page again. |
fetch, venue, product |
--archive- |
When the site refuses the page or is down, give a copy from the Wayback Machine or Common Crawl. The result marks it as archived, with its date. | |
fetch, venue, product |
--archive- |
With --archive-: also give a copy of a page that the current robots.txt of its site disallows. |
|
find |
--limit <n> |
10 |
The number of results. |
find |
--kind <kind> |
all | Only this kind of document, for example page or pdf. |
find |
--rank <mode> |
exact |
exact gives BM25 to each match. fast leaves the common words out of the documents that hold one word, so a long question is faster. hybrid also finds by meaning, and it needs --embedder. |
find, embed, mcp |
--embedder <name> |
$POLITE_ |
The local model of hybrid search: transformers (transformers.js in the process) or ollama. |
find, embed, mcp |
--embed- |
$POLITE_ |
The model: Xenova/ (transformers) or nomic- (Ollama) by default. |
find, embed, mcp |
--ollama- |
$POLITE_, or http:/ |
The Ollama server. It needs --embedder ollama. |
find, embed, mcp |
--allow- |
$POLITE_ |
Permit an Ollama server on a different computer. The page text goes to that server. |
read |
--from <n> |
0 |
The position where the range starts. |
read |
--length <n> |
4000 |
The number of characters to print. |
read |
--user- |
Read a page that asked not to be AI input. Use it only for a URL that you gave yourself. The crawler records each such read. | |
extract |
--field <name= |
A value to check. The kind is text (the default), number, money, date, url, email, phone or json-. Repeat the option for more fields. |
|
extract |
--capture <id> |
Check the text of this capture, not the current text. | |
extract |
--user- |
Check a page that asked not to be AI input, as for read. |
|
read, verify, extract |
--at <time> |
Use the version that was current at this time, for example 2026-. A date with no time is the start of that day in UTC. |
|
mcp |
--allow- |
$POLITE_ |
Let user_ work when the MCP client cannot ask the user. |
export |
--out <file> |
The archive to write. The command needs it. When the file exists, the command fails. | |
export |
--format <format> |
from the name of the file | warc (a .warc.gz file) or wacz (a .wacz file). |
export |
--since <time> |
Only the captures from this time on, for example 2026-. |
|
export |
--until <time> |
Only the captures before this time. | |
export |
--host <host> |
Only the captures of this host and its subdomains. | |
export |
--prefix <url> |
Only the captures whose URL starts with this text. | |
export |
--id <capture> |
Only this capture. Give --id again for more captures. |
|
export |
--include- |
Add a metadata record for each capture with no body: a refusal, a skip, an error or a redirect. |
|
export |
--overwrite |
Replace the file when it exists. | |
discover |
--max- |
1000 |
The most URLs to print. |
discover |
--feed <url> |
Read this RSS or Atom feed too. Repeat the option for more feeds. | |
crawl |
--max- |
100 |
The most pages to fetch. |
crawl |
--max- |
3 |
The most links from a seed to a page. 0 fetches only the seeds. |
crawl |
--budget <time> |
10m |
The longest time of the crawl, for example 30s or 2m. No request starts after it. |
crawl |
--include <pattern> |
Follow only the URLs that match. / matches a path. Repeat the option for more patterns. |
|
crawl |
--exclude <pattern> |
Follow no URL that matches, for example *.pdf$. Repeat the option for more patterns. |
|
crawl |
--sitemaps |
Add the pages of the sitemaps of the site, the newest first. | |
crawl, discover |
--allow- |
Keep the URLs on this host too. Repeat the option for more hosts. | |
diff |
--from <version> |
the version before --to |
The old version: a capture id, or a time. |
diff |
--to <version> |
the newest version | The new version: a capture id, or a time. |
watch add |
--every <time> |
24h |
The time between two checks. The floor is 1h, so a watch cannot hammer a site. |
watch add |
--confirm <n> |
2 |
2: a change counts when two checks see it. 1: a change counts at once. |
watch add |
--scope <text> |
A label for the captures of each check. | |
watch add |
--label <name= |
A label for the captures of each check. Repeat the option for more labels. | |
watch run |
--budget <time> |
10m |
The longest time of the run. No request starts after it, and an entry that it did not check stays due. |
watch run |
--max- |
100 |
The most pages to check. |
embed |
--budget <time> |
10m |
The longest time of the work. No embedding starts after it. |
embed |
--max- |
The most texts that get vectors. | |
embed |
--kind <kind> |
all | Only this kind of document, for example page or pdf. |
venue |
--name <text> |
The name of the venue. The output tells if the home page names it. A domain that a venue let go can show a different business. | |
venue |
--require- |
With --name: read no hours from a site that does not name the venue, and fetch no more pages. |
|
venue |
--address <text> |
The street address of the venue. On a page that lists more than one location, the recipe reads only this location. | |
venue |
--lat <n>, --lon <n> |
The position of the venue, for the same use. A location within 150 m matches. Write a number below zero after =, for example --lon=. |
|
venue |
--osm <value> |
An OpenStreetMap opening_ value. The recipe reads it as one more reading. It sends no request to OpenStreetMap. |
|
venue |
--pages <n> |
3 |
The pages after the home page, from 0 to 8. The recipe fetches the pages that most likely hold hours or a menu. |
venue |
--compare <file> |
Compare the week of the site with a week that you keep, as JSON. The venue and product section gives the format. | |
venue, product |
--budget <time> |
no limit | No request starts after this time, for example 2m. |
venue, product |
--on- |
Apply the robots.txt rules of this agent too, for example Claude-. Repeat the option for more agents. |
|
venue, product |
--user- |
Read a page that asked not to be AI input, as for read. |
Daemon
Section titled “Daemon”polite-crawler daemon checks the watch list on a schedule, until SIGINT or SIGTERM. Each tick is one watch run, so each polite rule applies. With --mcp-http, the daemon also serves the MCP tools over local HTTP. The MCP server is the package polite-crawler-mcp: install it next to polite-crawler. The daemon, tick by tick shows a schedule.
npx polite-crawler watch add https://example.com/hours --every 6hnpx polite-crawler daemon --events ~/changes.jsonl --on-change "jq -c . >> ~/seen.jsonl"npx polite-crawler daemon status| Option | Default | What it does |
|---|---|---|
--tick <time> |
1m |
The longest wait between two ticks, 1s or more. A tick comes sooner when an entry is due sooner. |
--jitter <time> |
10s |
A random wait from 0 to this time after each tick. A check does not come before its time. |
--tick- |
10m |
The longest time of the checks of one tick. The entries that stay due wait for the next tick. |
--tick- |
100 |
The most checks of one tick. |
--grace <time> |
10s |
At a stop, the checks in progress get this time to end. Then they abort, and the daemon releases their leases. |
--events <file> |
the standard output | The file of the changes, one JSON line for each change. |
--on- |
Your command for each change. It gets the event as one JSON line on its standard input. | |
--mcp- |
Serve the MCP tools over HTTP. Each request needs the bearer token. | |
--mcp- |
9307 |
The port of the MCP server. 0 takes a free port. |
--mcp- |
127.0.0.1 |
The host to bind. A host that is not loopback needs --allow-. |
--mcp- |
a new token at each start, in <store>/ |
The file of your token. The daemon reads it and writes nothing. |
--allow- |
Permit a --mcp- that is not loopback. Read the warning in the README first. |
|
--allow- |
$POLITE_ |
As for mcp. |
- A change is an event with
confirmed: true. The first version of a page is not a change. daemon statusreads<store>/daemon/state.json. It shows the next due watches, the last tick, the tasks that run and the last error.--jsonprints the JSON.daemon statusexits with0when a daemon operates on the store, and with1when no daemon operates.daemonexits with0after a clean stop.- Only one daemon operates on a store. A second daemon does not start.
--on-change starts a command of the operator in the shell of the system, as the user of the daemon. The event comes only on the standard input, not in the command line. The event holds URLs and notes from sites, so read it as data, for example with jq. Do not take the command from a page or from an assistant.
The package installs no service. The README of the package gives example files for systemd, launchd and the Task Scheduler of Windows.
Export to a web archive
Section titled “Export to a web archive”export writes WARC/1.1 or WACZ 1.1.1. Archive tools read it, for example warcio, pywb and ReplayWeb.page. The store stays private evidence, and an export is the choice of the operator. Thus the MCP server has no export tool.
- A capture with a body gives a
responserecord. A 304 gives arevisitrecord, and a rendered page gives aconversionrecord. - Each of these records has a
metadatarecord with the JSON of the capture: the outcome, the note, the robots.txt check and the usage signals. - A capture keeps only some headers. Thus the export rebuilds the HTTP header block from them, and it marks the record with
WARC-Polite-Crawler-Headers: rebuilt. - The export writes no
requestrecord and noWARC-IP-Address, because a capture does not keep them.
The README of the package tells what goes into the archive, what does not, and why.
Venue and product
Section titled “Venue and product”venue and product use the recipes of the package: readVenue and readProduct. Each page is a fetch of the crawler, so robots.txt, the pace and the capture log apply.
npx polite-crawler venue https://forno-esempio.example/ --name "Forno Esempio" --pages 2npx polite-crawler venue https://trattoria-campione.example/ --address "12 Via Esempio"npx polite-crawler venue https://forno-esempio.example/ --compare kept-week.jsonnpx polite-crawler product "https://bottega-campione.example/products/olio-esempio?variant=222"venue prints these lines:
- The week of the site (
from_site). It is the best reading of the site itself, with no guessed am or pm. - Each reading, the best first, with its rank, its source URL, its capture and its quote. The quote of a reading of the text is a quote for
verify. - The days where the readings disagree, with the hours of each reading on that day.
- The menus, the phone, the pages that the recipe fetched, and the notes. A note tells of a held-back page, a site that moved, or a page that lists more than one location.
venue --compare <file> compares the week of the site with a week that you keep, through compareHours. It prints same, changed, new or not read for each day. A changed day shows the kept hours and the new hours.
- The file is a week, for example
{"mon": [["07:00", "15:00"]], "sun": []}.[]andnullare a closed day. - A day can also give one interval,
["07:00", "15:00"], astoHoursWeekwrites it. - An object with the field
weekorhours_weekis correct too. Thus thefrom_siteofvenue --jsonis a kept week. - With
--json, the result gets the fieldcompare: the file, the kept week and thecomparison. Thecomparisonis null when the result has nofrom_site.
product prints the name, the brand, the SKU and the GTIN. Then it prints the price as an amount and an ISO 4217 code, and the range of the offers. Then come the availability, the variant of the URL and the seller. A wall and a held-back page say so.
--json prints the VenueResult or the ProductResult of the library.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
The command did its work. |
1 |
The command did not do its work. The causes are a page that the crawler did not fetch, no search result or a quote that is not in the document. A document that is not stored or that is held back, and an error, are causes too. discover gives 1 when it finds no URL, and crawl when it gets no page. read - and verify - give 1 for a time before the first capture. watch run gives 1 when a check is refused or an error, or when entries stay due. With --archive-, a page with an archived copy counts as done. extract gives 1 when a field is not verified or normalized. embed gives 1 when its budget stops it before each page has vectors. |
2 |
The command line is wrong. The command opens no store. |
3 |
venue and product read nothing: no opening hours of the site or no Product data, a page that is held back, or a page that did not come. |
4 |
venue and product: the site refused the crawler (a wall). The causes are a 401, a 402 or a 403, a challenge, a bot check, robots.txt or a stop of the host. The crawler does not try a different identity. |
Examples
Section titled “Examples”# two sites at the same time, one request at a time to eachnpx polite-crawler fetch https://example.com/ https://en.wikipedia.org/wiki/Web_crawler
# JSON for a programnpx polite-crawler find "opening hours" --limit 5 --json
# a store for one projectnpx polite-crawler fetch https://example.com/ --dir ./research
# a script that stops when a quote is not in the pagenpx polite-crawler verify "url:https://example.com/" "for use in documentation examples" || exit 1
# a script that stops when a proposed price is not on the pagenpx polite-crawler extract "url:https://example.com/" --field "price=4.50 EUR:money" || exit 1
# the captures of one site since 1 October, as a WACZ file for ReplayWeb.pagenpx polite-crawler export --out example.wacz --host example.com --since 2026-10-01
# the pages of a site from its sitemaps and feeds, with no fetch of the pagesnpx polite-crawler discover https://example.com/ --max-urls 200
# 50 pages of the blog of a site in 2 minutes or less, one request at a timenpx polite-crawler crawl https://example.com/blog/ --max-pages 50 --include "/blog/*" --budget 2m
# the page as it was on the morning of 1 Octobernpx polite-crawler read "url:https://example.com/" --at 2026-10-01T09:00:00Z
# what changed since 1 Octobernpx polite-crawler diff "url:https://example.com/" --from 2026-10-01
# check the hours page each 6 hours: add it one time, and let cron start the runnpx polite-crawler watch add https://example.com/hours --every 6hnpx polite-crawler watch run --budget 5m
# vectors for each stored page with Ollama, then a search by meaning and by wordsollama pull nomic-embed-textnpx polite-crawler embed --embedder ollama --budget 30mnpx polite-crawler find "a loaf with a dark crust" --rank hybrid --embedder ollama
# the hours of a venue from its own site, compared with the week that you keepnpx polite-crawler venue https://forno-esempio.example/ --compare kept-week.json
# the price of a product page as JSON for a program, and a stop at a wallnpx polite-crawler product "https://bottega-campione.example/products/olio-esempio" --json[ $? -eq 4 ] && echo "the shop refused the crawler"Discover and crawl
Section titled “Discover and crawl”discover reads the sitemaps that robots.txt names (or /sitemap.xml), the sitemap indexes, and the RSS and Atom feeds that the page links. It prints each URL with its lastmod, the newest first. It keeps only the URLs on the same site that robots.txt permits.
crawl prints each page when its fetch ends, then a summary. The summary gives the pages fetched, refused and failed, the links that it did not follow, and the reason of the stop.
- Each fetch obeys robots.txt and the pace of the site: one request at a time, and 3 seconds or more between two pages.
- When the budget ends, no new request starts.
- The first
Ctrl+Cstops the crawl, and the summary prints. --jsonprints the pages and the summary as one JSON object at the end.
Diff and watch
Section titled “Diff and watch”diff prints the changed lines as a unified diff, with 2 lines of context. A changed line marks its words with [-removed-] and {+added+}. Then it prints the changes of the title, the URL and the metadata at their paths, for example meta.jsonld[0].openingHours.
- The default compares the newest version with the version before it of the same kind (plain or rendered).
- A large change stays bounded. The note tells when the diff is not minimal or leaves out a part.
- A page that asked not to be AI input shows no text and no title.
diffthen gives1.
watch keeps a list of pages in the file watch.sqlite of the store. watch run fetches each page that is due, with each polite rule. It prints one line for each check: new, changed, unchanged, gone, refused or error.
- A change is
suspectedat its first check. The next check confirms it when it sees the same version. One read can be a glitch, so--confirm 2is the default. - A check that finds a stopped host is due again at the end of the stop.
- Two runs at the same time check each page one time, because a run takes a lease on each page.
- Start
watch runwith cron, a systemd timer or a different scheduler. Or let the daemon check the list.
Hybrid search
Section titled “Hybrid search”find --rank hybrid fuses the BM25 ranking with the ranking of the vectors of a local model. The default ranking does not change.
--embedder transformersuses transformers.js in the process. Install it withnpm install @huggingface/transformers. The first use downloads the model from the Hugging Face Hub into<store>/models, not through the polite crawler.--embedder ollamasends the texts to a local Ollama server. Install Ollama, thenollama pull nomic-embed-text. The command refuses a server on a different computer, unless--allow-remote-ollama.embedgives vectors to each stored page within--budget. Start it again to continue. A search gives vectors only to its BM25 candidates.- A page that asks not to be AI input does not go to the model, and no result gives it.
- The vectors go into
vectors.sqlitein the store. A reindex keeps them. - A hit gives its best chunk as
[passage start–end], with the positions in the text forread --from.