|
25 | 25 | | `brightdata scrape` | Scrape any URL — bypasses CAPTCHAs, JS rendering, anti-bot protections | |
26 | 26 | | `brightdata search` | Google / Bing / Yandex search with structured JSON output | |
27 | 27 | | `brightdata pipelines` | Extract structured data from 40+ platforms (Amazon, LinkedIn, TikTok…) | |
| 28 | +| `brightdata browser` | Control a real browser via Bright Data's Scraping Browser — navigate, snapshot, click, type, and more | |
28 | 29 | | `brightdata zones` | List and inspect your Bright Data proxy zones | |
29 | 30 | | `brightdata budget` | View account balance and per-zone cost & bandwidth | |
30 | 31 | | `brightdata skill` | Install Bright Data AI agent skills into your coding agent | |
|
44 | 45 | - [scrape](#scrape) |
45 | 46 | - [search](#search) |
46 | 47 | - [pipelines](#pipelines) |
| 48 | + - [browser](#browser) |
47 | 49 | - [status](#status) |
48 | 50 | - [zones](#zones) |
49 | 51 | - [budget](#budget) |
@@ -292,6 +294,333 @@ See [Dataset Types Reference](#dataset-types-reference) for the full list. |
292 | 294 |
|
293 | 295 | --- |
294 | 296 |
|
| 297 | +### `browser` |
| 298 | + |
| 299 | +Control a real browser session powered by [Bright Data's Scraping Browser](https://brightdata.com/products/scraping-browser). A lightweight local daemon holds the browser connection open between commands, giving you persistent state without reconnecting on every call. |
| 300 | + |
| 301 | +```bash |
| 302 | +brightdata browser open <url> # Start a session and navigate |
| 303 | +brightdata browser snapshot # Get an accessibility tree of the page |
| 304 | +brightdata browser screenshot [path] # Take a PNG screenshot |
| 305 | +brightdata browser click <ref> # Click an element |
| 306 | +brightdata browser type <ref> <text> # Type into an element |
| 307 | +brightdata browser fill <ref> <value> # Fill a form field |
| 308 | +brightdata browser select <ref> <value> # Select a dropdown option |
| 309 | +brightdata browser check <ref> # Check a checkbox / radio |
| 310 | +brightdata browser uncheck <ref> # Uncheck a checkbox |
| 311 | +brightdata browser hover <ref> # Hover over an element |
| 312 | +brightdata browser scroll # Scroll the page |
| 313 | +brightdata browser get text [selector] # Get text content |
| 314 | +brightdata browser get html [selector] # Get HTML content |
| 315 | +brightdata browser back # Navigate back |
| 316 | +brightdata browser forward # Navigate forward |
| 317 | +brightdata browser reload # Reload the page |
| 318 | +brightdata browser network # Show captured network requests |
| 319 | +brightdata browser cookies # Show cookies |
| 320 | +brightdata browser status # Show session state |
| 321 | +brightdata browser sessions # List all active sessions |
| 322 | +brightdata browser close # Close session and stop daemon |
| 323 | +``` |
| 324 | +
|
| 325 | +**Global flags** (work with every subcommand) |
| 326 | +
|
| 327 | +| Flag | Description | |
| 328 | +|---|---| |
| 329 | +| `--session <name>` | Session name — run multiple isolated sessions in parallel (default: `default`) | |
| 330 | +| `--country <code>` | Geo-target by ISO country code (e.g. `us`, `de`). On `open`, changing country reconnects the browser | |
| 331 | +| `--zone <name>` | Scraping Browser zone (default: `cli_browser`) | |
| 332 | +| `--timeout <ms>` | IPC command timeout in milliseconds (default: `30000`) | |
| 333 | +| `--idle-timeout <ms>` | Daemon auto-shutdown after idle (default: `600000` = 10 min) | |
| 334 | +| `--json` / `--pretty` | JSON output | |
| 335 | +| `-o, --output <path>` | Write output to file | |
| 336 | +| `-k, --api-key <key>` | Override API key | |
| 337 | +
|
| 338 | +--- |
| 339 | +
|
| 340 | +#### `browser open <url>` |
| 341 | +
|
| 342 | +Navigate to a URL. Starts the daemon and browser session automatically if not already running. |
| 343 | +
|
| 344 | +```bash |
| 345 | +brightdata browser open https://example.com |
| 346 | +brightdata browser open https://amazon.com --country us --session shop |
| 347 | +``` |
| 348 | +
|
| 349 | +| Flag | Description | |
| 350 | +|---|---| |
| 351 | +| `--country <code>` | Geo-targeting. Reconnects the browser if the country changes on an existing session | |
| 352 | +| `--zone <name>` | Browser zone name | |
| 353 | +| `--idle-timeout <ms>` | Daemon idle timeout for this session | |
| 354 | +
|
| 355 | +--- |
| 356 | +
|
| 357 | +#### `browser snapshot` |
| 358 | +
|
| 359 | +Capture the page as a text accessibility tree. This is the primary way AI agents read page content — far more token-efficient than raw HTML. |
| 360 | +
|
| 361 | +```bash |
| 362 | +brightdata browser snapshot |
| 363 | +brightdata browser snapshot --compact # Interactive elements + ancestors only |
| 364 | +brightdata browser snapshot --interactive # Interactive elements as a flat list |
| 365 | +brightdata browser snapshot --depth 3 # Limit tree depth |
| 366 | +brightdata browser snapshot --selector "main" # Scope to a CSS subtree |
| 367 | +brightdata browser snapshot --wrap # Wrap output in AI-safe content boundaries |
| 368 | +``` |
| 369 | +
|
| 370 | +**Output format:** |
| 371 | +``` |
| 372 | +Page: Example Domain |
| 373 | +URL: https://example.com |
| 374 | +
|
| 375 | +- heading "Example Domain" [level=1] |
| 376 | +- paragraph "This domain is for use in illustrative examples." |
| 377 | +- link "More information..." [ref=e1] |
| 378 | +``` |
| 379 | +
|
| 380 | +Each interactive element gets a `ref` (e.g. `e1`, `e2`) that you pass to `click`, `type`, `fill`, etc. |
| 381 | +
|
| 382 | +| Flag | Description | |
| 383 | +|---|---| |
| 384 | +| `--compact` | Only interactive elements and their ancestors (70–90% fewer tokens) | |
| 385 | +| `--interactive` | Only interactive elements, as a flat list | |
| 386 | +| `--depth <n>` | Limit tree depth to a non-negative integer | |
| 387 | +| `--selector <sel>` | Scope snapshot to elements matching a CSS selector | |
| 388 | +| `--wrap` | Wrap output in `--- BRIGHTDATA_BROWSER_CONTENT ... ---` boundaries (useful for AI agent prompt injection safety) | |
| 389 | +
|
| 390 | +--- |
| 391 | +
|
| 392 | +#### `browser screenshot [path]` |
| 393 | +
|
| 394 | +Capture a PNG screenshot of the current viewport. |
| 395 | +
|
| 396 | +```bash |
| 397 | +brightdata browser screenshot |
| 398 | +brightdata browser screenshot ./result.png |
| 399 | +brightdata browser screenshot --full-page -o page.png |
| 400 | +brightdata browser screenshot --base64 |
| 401 | +``` |
| 402 | +
|
| 403 | +| Flag | Description | |
| 404 | +|---|---| |
| 405 | +| `[path]` | Where to save the PNG (default: temp directory) | |
| 406 | +| `--full-page` | Capture the full scrollable page, not just the viewport | |
| 407 | +| `--base64` | Output base64-encoded PNG data instead of saving to a file | |
| 408 | +
|
| 409 | +--- |
| 410 | +
|
| 411 | +#### `browser click <ref>` |
| 412 | +
|
| 413 | +Click an element by its snapshot ref. |
| 414 | +
|
| 415 | +```bash |
| 416 | +brightdata browser click e3 |
| 417 | +brightdata browser click e3 --session shop |
| 418 | +``` |
| 419 | +
|
| 420 | +--- |
| 421 | +
|
| 422 | +#### `browser type <ref> <text>` |
| 423 | +
|
| 424 | +Type text into an element. Clears the field first by default. |
| 425 | +
|
| 426 | +```bash |
| 427 | +brightdata browser type e5 "search query" |
| 428 | +brightdata browser type e5 " more text" --append # Append to existing value |
| 429 | +brightdata browser type e5 "search query" --submit # Press Enter after typing |
| 430 | +``` |
| 431 | +
|
| 432 | +| Flag | Description | |
| 433 | +|---|---| |
| 434 | +| `--append` | Append to existing value using key-by-key simulation | |
| 435 | +| `--submit` | Press Enter after typing | |
| 436 | +
|
| 437 | +--- |
| 438 | +
|
| 439 | +#### `browser fill <ref> <value>` |
| 440 | +
|
| 441 | +Fill a form field directly (no keyboard simulation). Use `type` if you need to trigger `keydown`/`keyup` events. |
| 442 | +
|
| 443 | +```bash |
| 444 | +brightdata browser fill e2 "user@example.com" |
| 445 | +``` |
| 446 | +
|
| 447 | +--- |
| 448 | +
|
| 449 | +#### `browser select <ref> <value>` |
| 450 | +
|
| 451 | +Select a dropdown option by its visible label. |
| 452 | +
|
| 453 | +```bash |
| 454 | +brightdata browser select e4 "United States" |
| 455 | +``` |
| 456 | +
|
| 457 | +--- |
| 458 | +
|
| 459 | +#### `browser check <ref>` / `browser uncheck <ref>` |
| 460 | +
|
| 461 | +Check or uncheck a checkbox or radio button. |
| 462 | +
|
| 463 | +```bash |
| 464 | +brightdata browser check e7 |
| 465 | +brightdata browser uncheck e7 |
| 466 | +``` |
| 467 | +
|
| 468 | +--- |
| 469 | +
|
| 470 | +#### `browser hover <ref>` |
| 471 | +
|
| 472 | +Hover the mouse over an element (triggers hover states, tooltips, dropdowns). |
| 473 | +
|
| 474 | +```bash |
| 475 | +brightdata browser hover e2 |
| 476 | +``` |
| 477 | +
|
| 478 | +--- |
| 479 | +
|
| 480 | +#### `browser scroll` |
| 481 | +
|
| 482 | +Scroll the viewport or scroll an element into view. |
| 483 | +
|
| 484 | +```bash |
| 485 | +brightdata browser scroll # Scroll down 300px (default) |
| 486 | +brightdata browser scroll --direction up |
| 487 | +brightdata browser scroll --direction down --distance 600 |
| 488 | +brightdata browser scroll --ref e10 # Scroll element e10 into view |
| 489 | +``` |
| 490 | +
|
| 491 | +| Flag | Description | |
| 492 | +|---|---| |
| 493 | +| `--direction <dir>` | `up`, `down`, `left`, `right` (default: `down`) | |
| 494 | +| `--distance <px>` | Pixels to scroll (default: `300`) | |
| 495 | +| `--ref <ref>` | Scroll this element into view instead of the viewport | |
| 496 | +
|
| 497 | +--- |
| 498 | +
|
| 499 | +#### `browser get text [selector]` |
| 500 | +
|
| 501 | +Get the text content of the page or a scoped element. |
| 502 | +
|
| 503 | +```bash |
| 504 | +brightdata browser get text # Full page text |
| 505 | +brightdata browser get text "h1" # Text of the first h1 |
| 506 | +brightdata browser get text "#price" # Text inside #price |
| 507 | +``` |
| 508 | +
|
| 509 | +--- |
| 510 | +
|
| 511 | +#### `browser get html [selector]` |
| 512 | +
|
| 513 | +Get the HTML of the page or a scoped element. |
| 514 | +
|
| 515 | +```bash |
| 516 | +brightdata browser get html # Full page outer HTML |
| 517 | +brightdata browser get html ".product" # innerHTML of .product |
| 518 | +brightdata browser get html --pretty # JSON output with selector field |
| 519 | +``` |
| 520 | +
|
| 521 | +--- |
| 522 | +
|
| 523 | +#### `browser network` |
| 524 | +
|
| 525 | +Show HTTP requests captured since the last navigation. |
| 526 | +
|
| 527 | +```bash |
| 528 | +brightdata browser network |
| 529 | +brightdata browser network --json |
| 530 | +``` |
| 531 | +
|
| 532 | +**Example output:** |
| 533 | +``` |
| 534 | +Network Requests (5 total): |
| 535 | +[GET] https://example.com/ => [200] |
| 536 | +[GET] https://example.com/style.css => [200] |
| 537 | +[POST] https://api.example.com/track => [204] |
| 538 | +``` |
| 539 | +
|
| 540 | +--- |
| 541 | +
|
| 542 | +#### `browser cookies` |
| 543 | +
|
| 544 | +Show cookies for the active session. |
| 545 | +
|
| 546 | +```bash |
| 547 | +brightdata browser cookies |
| 548 | +brightdata browser cookies --pretty |
| 549 | +``` |
| 550 | +
|
| 551 | +--- |
| 552 | +
|
| 553 | +#### `browser status` |
| 554 | +
|
| 555 | +Show the current state of a browser session. |
| 556 | +
|
| 557 | +```bash |
| 558 | +brightdata browser status |
| 559 | +brightdata browser status --session shop --pretty |
| 560 | +``` |
| 561 | +
|
| 562 | +--- |
| 563 | +
|
| 564 | +#### `browser sessions` |
| 565 | +
|
| 566 | +List all active browser daemon sessions. |
| 567 | +
|
| 568 | +```bash |
| 569 | +brightdata browser sessions |
| 570 | +brightdata browser sessions --pretty |
| 571 | +``` |
| 572 | +
|
| 573 | +--- |
| 574 | +
|
| 575 | +#### `browser close` |
| 576 | +
|
| 577 | +Close a session and stop its daemon. |
| 578 | +
|
| 579 | +```bash |
| 580 | +brightdata browser close # Close the default session |
| 581 | +brightdata browser close --session shop # Close a named session |
| 582 | +brightdata browser close --all # Close all active sessions |
| 583 | +``` |
| 584 | +
|
| 585 | +--- |
| 586 | +
|
| 587 | +**Example: AI agent workflow** |
| 588 | +
|
| 589 | +```bash |
| 590 | +# Open a US-targeted session |
| 591 | +brightdata browser open https://example.com --country us |
| 592 | +
|
| 593 | +# Read the page structure (compact for token efficiency) |
| 594 | +brightdata browser snapshot --compact |
| 595 | +
|
| 596 | +# Interact using refs from the snapshot |
| 597 | +brightdata browser click e3 |
| 598 | +brightdata browser type e5 "search query" --submit |
| 599 | +
|
| 600 | +# Get updated snapshot after interaction |
| 601 | +brightdata browser snapshot --compact |
| 602 | +
|
| 603 | +# Save a screenshot for visual verification |
| 604 | +brightdata browser screenshot ./result.png |
| 605 | +
|
| 606 | +# Done |
| 607 | +brightdata browser close |
| 608 | +``` |
| 609 | +
|
| 610 | +**Example: multi-session comparison** |
| 611 | +
|
| 612 | +```bash |
| 613 | +brightdata browser open https://amazon.com --session us --country us |
| 614 | +brightdata browser open https://amazon.com --session de --country de |
| 615 | +
|
| 616 | +brightdata browser snapshot --session us --json > us.json |
| 617 | +brightdata browser snapshot --session de --json > de.json |
| 618 | +
|
| 619 | +brightdata browser close --all |
| 620 | +``` |
| 621 | +
|
| 622 | +--- |
| 623 | +
|
295 | 624 | ### `status` |
296 | 625 |
|
297 | 626 | Check the status of an async snapshot job (returned by `--async` or `pipelines`). |
@@ -516,6 +845,8 @@ CLI flags → Environment variables → config.json → Defaults |
516 | 845 | | `BRIGHTDATA_UNLOCKER_ZONE` | Default Web Unlocker zone | |
517 | 846 | | `BRIGHTDATA_SERP_ZONE` | Default SERP zone | |
518 | 847 | | `BRIGHTDATA_POLLING_TIMEOUT` | Default polling timeout in seconds | |
| 848 | +| `BRIGHTDATA_BROWSER_ZONE` | Default Scraping Browser zone (default: `cli_browser`) | |
| 849 | +| `BRIGHTDATA_DAEMON_DIR` | Override the directory used for browser daemon socket and PID files | |
519 | 850 |
|
520 | 851 | ```bash |
521 | 852 | BRIGHTDATA_API_KEY=xxx BRIGHTDATA_UNLOCKER_ZONE=my_zone \ |
@@ -671,6 +1002,29 @@ brightdata pipelines amazon_product <url> --timeout 1200 |
671 | 1002 | export BRIGHTDATA_POLLING_TIMEOUT=1200 |
672 | 1003 | ``` |
673 | 1004 |
|
| 1005 | +**`No active browser session "default"`** |
| 1006 | +```bash |
| 1007 | +# Start a session first |
| 1008 | +brightdata browser open https://example.com |
| 1009 | +``` |
| 1010 | +
|
| 1011 | +**Browser daemon won't start** |
| 1012 | +```bash |
| 1013 | +# Check if a stale socket file exists and clear it |
| 1014 | +brightdata browser close |
| 1015 | +# Then retry |
| 1016 | +brightdata browser open https://example.com |
| 1017 | +``` |
| 1018 | +
|
| 1019 | +**Element ref not found after interaction** |
| 1020 | +
|
| 1021 | +Refs are re-assigned on every `snapshot` call. If you navigate or click (which may cause the page to change), take a fresh snapshot before using refs again: |
| 1022 | +```bash |
| 1023 | +brightdata browser click e3 |
| 1024 | +brightdata browser snapshot --compact # refresh refs |
| 1025 | +brightdata browser type e5 "text" |
| 1026 | +``` |
| 1027 | +
|
674 | 1028 | **Garbled output in non-interactive terminal** |
675 | 1029 |
|
676 | 1030 | Colors and spinners are disabled automatically when not in a TTY. If you still see ANSI codes, add `| cat` at the end of your command. |
|
0 commit comments