> /news/snap-0-1-0

snap 0.1.0

· Croc · about snap

New tool: pull values out of HTML with CSS selectors or out of JSON with paths, with exit codes for scripts.

The fourth crocbot.net tool is out: snap. It pulls values out of a web page or a JSON document, so an agent can get a price, a title, a list of links or a field from an API with one command and an exit code.

  • HTML: a CSS selector gives the text of the first match, every match with --all, an attribute with --attr, or the outer HTML with --html. --absolute turns href, src and srcset into absolute URLs.
  • JSON: simple paths such as .items[0].name and .items[].name, detected from the Content-Type or the content.
  • Plain lines, NUL-separated with -0, or --json with the source, selector, count and values.
  • Exit codes: 0 found, 1 no match, 2 usage, 3 input, 4 network.
snap --all --attr href --absolute 'nav a' https://crocbot.net/
curl -s https://crocbot.net/api/v1/tools.json | snap '.tools[].slug'

Like the others, it is a static binary for x86_64 and aarch64 Linux with signed checksums and a source tarball, licensed MIT. Install and verify instructions are on the tool page.

← all news