Skip to content

Command line

Terminal window
npx polite-crawler <command> [options]
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> --field name=value[:kind] 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-crawler-mcp on the standard input and output, and 0.3.0 removes it. Without that package, it tells you to start npx polite-crawler-mcp and exits with 2.
export --out <file> 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-http, it also serves the MCP tools over local HTTP, with the package polite-crawler-mcp.
daemon status It prints the state of the daemon of the store. It opens no store.
key-directory It prints the key directory (a JSON Web Key Set) of --sign-key, for you to host.
embed --embedder <name> It gives vectors to the stored pages that have none, for find --rank hybrid. 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.

These options apply to each command:

Option Default What it does
--dir <path> $POLITE_CRAWLER_DIR, or ~/.polite-crawler The store. A path that starts with ~ is in your home folder, and a relative path starts at the working folder.
--contact <text> $POLITE_CRAWLER_CONTACT An email (in From and the User-Agent) or a URL (in the User-Agent only).
--allow-private $POLITE_CRAWLER_ALLOW_PRIVATE=1 Fetch loopback, private and link-local addresses too. By default, the crawler refuses them.
--no-browser Do not open the headless browser.
--sign-key <file> $POLITE_CRAWLER_SIGN_KEY Sign each request (Web Bot Auth) with this Ed25519 key: PKCS#8 PEM or a JWK. It needs --signature-agent. fetch, discover, crawl, watch run, mcp, key-directory, venue and product take it.
--signature-agent <url> $POLITE_CRAWLER_SIGNATURE_AGENT 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-age <age> 24h A stored copy younger than this age answers with no request. 0 fetches the page again.
fetch, venue, product --archive-fallback 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-despite-robots With --archive-fallback: 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_CRAWLER_EMBEDDER The local model of hybrid search: transformers (transformers.js in the process) or ollama.
find, embed, mcp --embed-model <name> $POLITE_CRAWLER_EMBED_MODEL The model: Xenova/bge-small-en-v1.5 (transformers) or nomic-embed-text (Ollama) by default.
find, embed, mcp --ollama-url <url> $POLITE_CRAWLER_OLLAMA_URL, or http://127.0.0.1:11434 The Ollama server. It needs --embedder ollama.
find, embed, mcp --allow-remote-ollama $POLITE_CRAWLER_ALLOW_REMOTE_OLLAMA=1 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-provided 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=value[:kind]> A value to check. The kind is text (the default), number, money, date, url, email, phone or json-ld:<path>. Repeat the option for more fields.
extract --capture <id> Check the text of this capture, not the current text.
extract --user-provided 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-10-01T12:00:00Z. A date with no time is the start of that day in UTC.
mcp --allow-user-provided $POLITE_CRAWLER_ALLOW_USER_PROVIDED=1 Let user_provided 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-10-01.
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-refusals 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-urls <n> 1000 The most URLs to print.
discover --feed <url> Read this RSS or Atom feed too. Repeat the option for more feeds.
crawl --max-pages <n> 100 The most pages to fetch.
crawl --max-depth <n> 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. /blog/* 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-host <host> 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=value> 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-pages <n> 100 The most pages to check.
embed --budget <time> 10m The longest time of the work. No embedding starts after it.
embed --max-docs <n> 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-name 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=-20.5.
venue --osm <value> An OpenStreetMap opening_hours 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-behalf-of <agent> Apply the robots.txt rules of this agent too, for example Claude-User. Repeat the option for more agents.
venue, product --user-provided Read a page that asked not to be AI input, as for read.

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.

Terminal window
npx polite-crawler watch add https://example.com/hours --every 6h
npx 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-budget <time> 10m The longest time of the checks of one tick. The entries that stay due wait for the next tick.
--tick-pages <n> 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-change <command> Your command for each change. It gets the event as one JSON line on its standard input.
--mcp-http Serve the MCP tools over HTTP. Each request needs the bearer token.
--mcp-port <n> 9307 The port of the MCP server. 0 takes a free port.
--mcp-host <host> 127.0.0.1 The host to bind. A host that is not loopback needs --allow-remote.
--mcp-token-file <file> a new token at each start, in <store>/daemon/mcp-token The file of your token. The daemon reads it and writes nothing.
--allow-remote Permit a --mcp-host that is not loopback. Read the warning in the README first.
--allow-user-provided $POLITE_CRAWLER_ALLOW_USER_PROVIDED=1 As for mcp.
  • A change is an event with confirmed: true. The first version of a page is not a change.
  • daemon status reads <store>/daemon/state.json. It shows the next due watches, the last tick, the tasks that run and the last error. --json prints the JSON.
  • daemon status exits with 0 when a daemon operates on the store, and with 1 when no daemon operates. daemon exits with 0 after 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 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 response record. A 304 gives a revisit record, and a rendered page gives a conversion record.
  • Each of these records has a metadata record 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 request record and no WARC-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 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.

Terminal window
npx polite-crawler venue https://forno-esempio.example/ --name "Forno Esempio" --pages 2
npx polite-crawler venue https://trattoria-campione.example/ --address "12 Via Esempio"
npx polite-crawler venue https://forno-esempio.example/ --compare kept-week.json
npx 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": []}. [] and null are a closed day.
  • A day can also give one interval, ["07:00", "15:00"], as toHoursWeek writes it.
  • An object with the field week or hours_week is correct too. Thus the from_site of venue --json is a kept week.
  • With --json, the result gets the field compare: the file, the kept week and the comparison. The comparison is null when the result has no from_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.

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 --at and verify --at 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-fallback, 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.
Terminal window
# two sites at the same time, one request at a time to each
npx polite-crawler fetch https://example.com/ https://en.wikipedia.org/wiki/Web_crawler
# JSON for a program
npx polite-crawler find "opening hours" --limit 5 --json
# a store for one project
npx polite-crawler fetch https://example.com/ --dir ./research
# a script that stops when a quote is not in the page
npx 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 page
npx 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.page
npx 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 pages
npx 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 time
npx polite-crawler crawl https://example.com/blog/ --max-pages 50 --include "/blog/*" --budget 2m
# the page as it was on the morning of 1 October
npx polite-crawler read "url:https://example.com/" --at 2026-10-01T09:00:00Z
# what changed since 1 October
npx 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 run
npx polite-crawler watch add https://example.com/hours --every 6h
npx polite-crawler watch run --budget 5m
# vectors for each stored page with Ollama, then a search by meaning and by words
ollama pull nomic-embed-text
npx polite-crawler embed --embedder ollama --budget 30m
npx 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 keep
npx 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 wall
npx polite-crawler product "https://bottega-campione.example/products/olio-esempio" --json
[ $? -eq 4 ] && echo "the shop refused the crawler"

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+C stops the crawl, and the summary prints.
  • --json prints the pages and the summary as one JSON object at the end.

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. diff then gives 1.

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 suspected at its first check. The next check confirms it when it sees the same version. One read can be a glitch, so --confirm 2 is 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 run with cron, a systemd timer or a different scheduler. Or let the daemon check the list.

find --rank hybrid fuses the BM25 ranking with the ranking of the vectors of a local model. The default ranking does not change.

  • --embedder transformers uses transformers.js in the process. Install it with npm install @huggingface/transformers. The first use downloads the model from the Hugging Face Hub into <store>/models, not through the polite crawler.
  • --embedder ollama sends the texts to a local Ollama server. Install Ollama, then ollama pull nomic-embed-text. The command refuses a server on a different computer, unless --allow-remote-ollama.
  • embed gives 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.sqlite in the store. A reindex keeps them.
  • A hit gives its best chunk as [passage start–end], with the positions in the text for read --from.