﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage examples

> Real-world workflows and recipes for the Bright Data CLI, from 1-line scrapes returning clean markdown to scheduled pipelines feeding LLMs.

## How to scrape with the CLI

### Get clean content from any website

```bash theme={null}
# Clean markdown - great for reading or feeding to LLMs
brightdata scrape https://news.ycombinator.com

# Save to file
brightdata scrape https://docs.python.org/3/tutorial/ -o python-tutorial.md

# Get raw HTML for parsing
brightdata scrape https://example.com -f html -o page.html
```

### How to scrape with geo-targeting

```bash theme={null}
# See Amazon prices as a US customer
brightdata scrape https://amazon.com/dp/B09V3KXJPB --country us

# Scrape a German news site from Germany
brightdata scrape https://spiegel.de --country de

# Mobile user agent for mobile-optimized pages
brightdata scrape https://example.com --mobile
```

### How to take screenshots

```bash theme={null}
# Full-page screenshot
brightdata scrape https://example.com -f screenshot -o homepage.png

# Screenshot from a specific country
brightdata scrape https://amazon.co.uk -f screenshot --country gb -o uk-amazon.png
```

***

## How to run search workflows

### Basic web search

```bash theme={null}
# Google search with formatted table output
brightdata search "best web scraping tools 2025"

# Get raw JSON for processing
brightdata search "typescript best practices" --json

# Pretty-print for inspection
brightdata search "AI startups" --pretty
```

### Localized and specialized search

```bash theme={null}
# Local restaurant search from Germany, in German
brightdata search "restaurants berlin" --country de --language de

# News-only results
brightdata search "AI regulation 2025" --type news

# Shopping results
brightdata search "wireless headphones" --type shopping

# Image search
brightdata search "mountain landscape wallpaper" --type images
```

### Pagination

```bash theme={null}
# First page (default)
brightdata search "web scraping tutorials"

# Second page
brightdata search "web scraping tutorials" --page 1

# Third page
brightdata search "web scraping tutorials" --page 2
```

***

## How to run browser workflows

### Navigate and read pages

```bash theme={null}
# Open a page and read its content
brightdata browser open https://example.com
brightdata browser snapshot

# Compact snapshot for AI agents (70-90% fewer tokens)
brightdata browser snapshot --compact

# Scope to a specific section
brightdata browser snapshot --selector "main"
```

### Interact with pages

```bash theme={null}
# Open a page
brightdata browser open https://example.com

# Read the page structure
brightdata browser snapshot --compact

# Click, type, and submit using refs from the snapshot
brightdata browser click e3
brightdata browser type e5 "search query" --submit

# Get updated snapshot after interaction
brightdata browser snapshot --compact

# Take a screenshot for visual verification
brightdata browser screenshot ./result.png

# Clean up
brightdata browser close
```

### How to compare multiple sessions

```bash theme={null}
# Open the same page from different countries
brightdata browser open https://amazon.com --session us --country us
brightdata browser open https://amazon.com --session de --country de

# Capture both snapshots
brightdata browser snapshot --session us --json > us.json
brightdata browser snapshot --session de --json > de.json

# Close all sessions
brightdata browser close --all
```

### Extract content from dynamic pages

```bash theme={null}
# Navigate to a page that requires JavaScript
brightdata browser open https://example.com/dashboard

# Get text content from specific elements
brightdata browser get text "#total-revenue"
brightdata browser get text ".summary-table"

# Get HTML for parsing
brightdata browser get html ".product-grid"

# Check network requests
brightdata browser network
```

***

## Structured data extraction

### How to find a pre-built scraper

`brightdata pipelines` runs any of the thousands of pre-built Scraper API scrapers. Look up the scraper first, then read the input fields of the method you want:

```bash theme={null}
# Search by site or data type: returns dataset_id, name, domain and collection_methods
brightdata pipelines search amazon reviews

# List the scraper's collection methods
brightdata pipelines info gd_le8e811kzy4ggddlq

# Show one method's input fields, an example input and a ready-to-run command
brightdata pipelines info gd_le8e811kzy4ggddlq collect_by_url
```

`collect_by_url` returns one record per URL. `discover_by_*` methods return many records per input, up to `--limit-per-input` (default 10). Use method names exactly as `info` lists them. An unknown field or a missing required field stops the command before the run starts, so nothing is billed.

### How to extract e-commerce data

```bash theme={null}
# Amazon product details, one record per URL
brightdata pipelines run gd_l7q7dkf244hwjntr0 collect_by_url "https://www.amazon.com/dp/B0FQFB8FMG"

# Amazon reviews, up to 20 per product
brightdata pipelines run gd_le8e811kzy4ggddlq collect_by_url "https://www.amazon.com/dp/B0FQFB8FMG" --max_reviews 20

# Walmart products by keyword, capped at 5 records (every record is billed)
brightdata pipelines run gd_l95fol7l1ru6rlo116 discover_by_keyword \
  --keyword "wireless headphones" --domain "https://www.walmart.com/" --limit-per-input 5

# Export as CSV
brightdata pipelines run gd_l7q7dkf244hwjntr0 collect_by_url "https://www.amazon.com/dp/B0FQFB8FMG" --format csv -o product.csv
```

### Social media profiles

```bash theme={null}
# LinkedIn person
brightdata pipelines run gd_l1viktl72bvl7bjuj0 collect_by_url "https://www.linkedin.com/in/satyanadella"

# LinkedIn company
brightdata pipelines run gd_l1vikfnt1wgvvqz95w collect_by_url "https://www.linkedin.com/company/bright-data"

# Two Instagram profiles in one run, one record per URL
brightdata pipelines run gd_l1vikfch901nx3by4 collect_by_url \
  "https://www.instagram.com/australiazoo" "https://www.instagram.com/zoobarcelona"
```

### Reviews and comments

```bash theme={null}
# Google Maps reviews from the last 7 days
brightdata pipelines run gd_luzfs1dn2oa0teb81 collect_by_url "<google_maps_place_url>" --days_limit 7

# YouTube comments, top 50
brightdata pipelines run gd_lk9q0ew71spt1mxywf collect_by_url "https://www.youtube.com/watch?v=dQw4w9WgXcQ" --num_of_comments 50

# Facebook company reviews, 25 reviews
brightdata pipelines run gd_m0dtqpiu1mbcyc2g86 collect_by_url "https://www.facebook.com/KFC/reviews/" --num_of_reviews 25
```

Records with an `error` field explain inputs that failed, such as a URL of the wrong type.

***

## Piping and automation

The CLI is designed to be pipe-friendly. When stdout is not a TTY, colors and spinners are automatically disabled.

### Chain search → scrape

```bash theme={null}
# Search Google, extract the first URL, then scrape it
brightdata search "best python frameworks 2025" --json \
  | jq -r '.organic[0].link' \
  | xargs brightdata scrape
```

### Scrape and read in terminal

```bash theme={null}
# Pipe markdown output to a terminal reader
brightdata scrape https://docs.github.com | glow -

# Or use less
brightdata scrape https://docs.github.com | less
```

### Export to CSV for analysis

```bash theme={null}
# Amazon product data to CSV
brightdata pipelines run gd_l7q7dkf244hwjntr0 collect_by_url "https://www.amazon.com/dp/B0FQFB8FMG" --format csv > product.csv

# LinkedIn job listing to CSV
brightdata pipelines run gd_lpfll7v5hcqtkxl6l collect_by_url \
  "https://www.linkedin.com/jobs/view/software-engineer-at-pave-4310512612/" --format csv -o jobs.csv
```

### Extract specific fields with jq

```bash theme={null}
# Get just the titles and prices from an Amazon keyword search
brightdata pipelines run gd_l7q7dkf244hwjntr0 discover_by_keyword --keyword "laptop" --limit-per-input 5 \
  | jq '[.[] | {title, price: .final_price}]'

# Get just organic result URLs from search
brightdata search "web scraping" --json | jq -r '.organic[].link'
```

### Async jobs for heavy workloads

```bash theme={null}
# Start a run without waiting; --async prints the snapshot ID
SNAPSHOT_ID=$(brightdata pipelines run <dataset_id> <method> "<url>" --async --json | jq -r '.snapshot_id')

# Do other work...

# Check back later, then fetch the records
brightdata pipelines status $SNAPSHOT_ID --wait
brightdata pipelines results $SNAPSHOT_ID --pretty
```

***

## How to manage your account

### Monitor costs

```bash theme={null}
# Quick balance check
brightdata budget

# Detailed balance with pending charges
brightdata budget balance

# Cost breakdown by zone
brightdata budget zones

# Specific zone in a date range
brightdata budget zone cli_unlocker --from 2024-01-01T00:00:00 --to 2024-02-01T00:00:00
```

### Manage configuration

```bash theme={null}
# View current config
brightdata config

# Set default output to JSON
brightdata config set default_format json

# Use a custom zone for scraping
brightdata config set default_zone_unlocker my_custom_zone

# Override SERP zone
brightdata config set default_zone_serp my_serp_zone
```

***

## AI agent integration

### Add the MCP server to your coding agent

```bash theme={null}
# Interactive - choose agent and scope
brightdata add mcp

# Add to Claude Code globally
brightdata add mcp --agent claude-code --global

# Add to multiple agents at once
brightdata add mcp --agent claude-code,cursor --project

# Add to Codex
brightdata add mcp --agent codex --global
```

### Install skills into coding agents

```bash theme={null}
# Interactive picker - choose skills and target agents
brightdata skill add

# Install the scraping skill into your agent
brightdata skill add scrape

# Install search capabilities
brightdata skill add search

# See all available skills
brightdata skill list
```

> [!TIP]
>
> Skills are pre-packaged bundles of prompts and configuration that teach AI coding agents how to use Bright Data effectively. See [For your coding agent](https://docs.brightdata.com/quickstart-coding-agent.md) and [github.com/brightdata/skills](https://github.com/brightdata/skills) for more details.

***

## Supported environment variables

Override any stored configuration with environment variables:

| Variable | Purpose |
| - | - |
| `BRIGHTDATA_API_KEY` | API key (skips login entirely) |
| `BRIGHTDATA_UNLOCKER_ZONE` | Default Web Unlocker zone |
| `BRIGHTDATA_SERP_ZONE` | Default SERP zone |
| `BRIGHTDATA_POLLING_TIMEOUT` | Polling timeout in seconds |
| `BRIGHTDATA_BROWSER_ZONE` | Default Scraping Browser zone (default: `cli_browser`) |
| `BRIGHTDATA_DAEMON_DIR` | Directory for the browser daemon socket and state. Defaults to the CLI config directory for your OS |

```bash theme={null}
# Use in CI/CD without login
BRIGHTDATA_API_KEY=your_key brightdata scrape https://example.com

# Override timeout for large pipeline jobs
BRIGHTDATA_POLLING_TIMEOUT=1200 brightdata pipelines run <dataset_id> <method> "<url>"
```
