browser4-cli 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -143,7 +143,7 @@ The tables below mirror the commands surfaced by the global `browser4-cli help`
143
143
  | `check <ref>` | Check a checkbox or radio button |
144
144
  | `uncheck <ref>` | Uncheck a checkbox or radio button |
145
145
  | `drag <startRef> <endRef>` | Drag and drop between two elements |
146
- | `snapshot` | Capture accessibility snapshot. Supports `--filename=<path>` to save to file, `--boxes` for bounding boxes, `-i`/`--interactive` for interactive-only, `-u`/`--urls` for link URLs, `-c`/`--compact` for compact output, `-d`/`--depth <n>` for depth limiting, and `-s`/`--selector <sel>` for CSS scoping. |
146
+ | `snapshot` | Capture accessibility snapshot. Supports `--filename=<path>` to save to file, `--boxes` for bounding boxes, `-i`/`--interactive` for interactive-only, `-u`/`--urls` for link URLs, `-c`/`--compact` for compact output, `-d`/`--depth <n>` for depth limiting, `-s`/`--selector <sel>` for CSS scoping, and `--raw` for raw output without page info. |
147
147
  | `eval <expression> [ref]` | Evaluate JavaScript on the page or a target element. Use `--file=<path>` to read the expression from a file. |
148
148
  | `get <mode> <selector> [name]` | Extract data from a page element. Modes: `text`, `html`, `box`, `styles`, `property`, `attr`. `name` is required for `property` and `attr`. |
149
149
  | `scroll <direction> <pixels>` | Scroll the page. Direction: `up`, `down`, `left`, or `right`. |
@@ -280,6 +280,7 @@ Query `browser4-cli help <command>` for the exact syntax when you need them.
280
280
  | `swarm query <url>` | Run an X-SQL query against a loaded webpage |
281
281
  | `swarm status <id>` | Check the status of a scrape or query job |
282
282
  | `swarm result <id>` | Get the result of a completed job |
283
+ | `crawl <url>` | Crawl a website from a seed URL, following links up to a configurable depth |
283
284
 
284
285
  ## Agent task workflow (`agent <subcommand>`)
285
286
 
@@ -381,6 +382,8 @@ coordinates multiple browser contexts in the Browser4 backend.
381
382
  | `swarm query <url>` | Run X-SQL queries against loaded pages | `POST /api/swarm/query` |
382
383
  | `swarm status <id>` | Poll job status | `GET /api/swarm/{id}/status` |
383
384
  | `swarm result <id>` | Fetch completed job result | `GET /api/swarm/{id}/result` |
385
+ | `crawl <url>` | Start a website crawl | `POST /api/crawl` |
386
+ | (poll) | Track crawl progress | `GET /api/crawl/{id}/result` |
384
387
 
385
388
  ### URL scraping with `swarm submit`
386
389
 
@@ -438,6 +441,57 @@ browser4-cli swarm query --sql @query.sql --seed-file=./urls.txt --refresh
438
441
  - Prefix the `--sql` value with `@` to read from a file (e.g. `--sql @query.sql`).
439
442
  - All commands return a task ID; use `swarm status` / `swarm result` to track progress.
440
443
 
444
+ ## Crawl (`crawl`)
445
+
446
+ Recursive website crawling from a seed URL.
447
+
448
+ ### Command overview
449
+
450
+ | Command | Purpose | Backend endpoint |
451
+ |---|---|---|
452
+ | `crawl <url>` | Crawl a website from a seed URL | `POST /api/crawl` |
453
+ | (poll) | Track crawl progress | `GET /api/crawl/{id}/result` |
454
+
455
+ ### Basic crawling
456
+
457
+ ```shell
458
+ # depth=1: extract all links from homepage, load each linked page
459
+ browser4-cli crawl "https://example.com" --out-link-selector "a[href]"
460
+
461
+ # depth=2: follow links two levels deep, filter by pattern
462
+ browser4-cli crawl "https://shop.example.com" \
463
+ --depth 2 \
464
+ --out-link-selector "a.product-link" \
465
+ --out-link-pattern "/product/" \
466
+ --top-links 10
467
+
468
+ # with LoadOptions passthrough
469
+ browser4-cli crawl "https://example.com" -ol "a[href]" -a "-refresh -nMaxRetry 5"
470
+ ```
471
+
472
+ ### Key flags
473
+
474
+ | Flag | Default | Description |
475
+ |---|---|---|
476
+ | `-d`, `--depth` | `1` | Maximum crawl depth |
477
+ | `-ol`, `--out-link-selector` | — | CSS selector to extract links from each page |
478
+ | `-olp`, `--out-link-pattern` | `.+` | Regex pattern to filter extracted links |
479
+ | `-tl`, `--top-links` | `20` | Maximum links to extract per page |
480
+ | `-a`, `--args` | — | Additional LoadOptions passthrough |
481
+ | `--refresh` | — | Force a fresh fetch, ignoring cache |
482
+ | `--parse` | — | Parse each page immediately after fetching |
483
+ | `--expires` | — | Cache expiration duration |
484
+ | `--store-content` | — | Persist page content to storage |
485
+ | `--page-load-timeout` | — | Maximum time to wait for page load |
486
+ | `--readonly` | — | Non-destructive mode |
487
+
488
+ ### Notes
489
+
490
+ - All LoadOptions flags available via `--args` passthrough (e.g. `-a "-nMaxRetry 5 -lazyFlush"`).
491
+ - Depth=1 reuses `PulsarSession.submitForOutPages`; depth>1 uses BFS continuous crawl with visited-URL dedup.
492
+ - CLI timeout: 600s default, configurable via `BROWSER4_CLI_CRAWL_TIMEOUT_SECS`.
493
+ - Duplicate URLs are skipped (normalized: lowercase, no trailing slash, no query string).
494
+
441
495
  ## DOM Snapshot commands (`domsnapshot <subcommand>`)
442
496
 
443
497
  The `domsnapshot` commands capture and query a **static DOM snapshot** of the
@@ -462,6 +516,37 @@ browser4-cli domsnapshot export --file=page.html
462
516
  | `domsnapshot get <field> [selector] [name]` | Extract elements from the static DOM snapshot |
463
517
  | `domsnapshot query [url] --sql=<query>` | Run X-SQL against the DOM snapshot via the scrape API |
464
518
  | `domsnapshot export [--file=<path>]` | Save full snapshot HTML content to a local file |
519
+ | `domsnapshot grep [OPTIONS] <pattern>` | Search snapshot HTML with regex and grep-style output |
520
+
521
+ ### `domsnapshot grep` flags
522
+
523
+ Line numbers are shown by default (unlike GNU grep). Use `--no-line-number` to suppress them.
524
+
525
+ | Flag | Description |
526
+ |---|---|
527
+ | `-i` | Case-insensitive matching |
528
+ | `-A N`, `-B N`, `-C N` | Context lines after / before / around each match |
529
+ | `-v` | Invert match (select non-matching lines) |
530
+ | `-c` | Print only count of matching lines |
531
+ | `-l` | Print only whether matches exist (prints "domsnapshot" if matches found; use with `\| grep -q domsnapshot` for CI pass/fail) |
532
+ | `-F` | Treat pattern as a literal string |
533
+ | `-w` | Match whole words only |
534
+ | `--no-line-number` | Suppress line numbers in output |
535
+ | `--selector <CSS>` | Scope search to a CSS selector |
536
+
537
+ ```shell
538
+ # Basic search
539
+ browser4-cli domsnapshot grep -i error
540
+
541
+ # With context and literal match
542
+ browser4-cli domsnapshot grep -F -C 2 "404 Not Found"
543
+
544
+ # Count matches
545
+ browser4-cli domsnapshot grep -c "div"
546
+
547
+ # Search within a specific element
548
+ browser4-cli domsnapshot grep --selector main "Submit"
549
+ ```
465
550
 
466
551
  ### `domsnapshot get` fields
467
552
 
@@ -609,6 +694,9 @@ browser4-cli snapshot -i -c -d 5
609
694
  # Scope snapshot to a specific CSS selector
610
695
  browser4-cli snapshot -s "#main-content"
611
696
 
697
+ # Raw output — no page info, just the snapshot content (useful for piping)
698
+ browser4-cli snapshot --raw | grep "button"
699
+
612
700
  # Capture a static DOM snapshot and extract data
613
701
  browser4-cli domsnapshot
614
702
  browser4-cli domsnapshot get text "#productTitle"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [