|
10 | 10 | - Monitor RSS feeds |
11 | 11 | - Crawl sites |
12 | 12 |
|
| 13 | +### IMPORTANT: Do NOT pipe commands together |
| 14 | + |
| 15 | +Commands are **sequential, not piped**. Each command reads from the session state (cached page), not stdin. |
| 16 | + |
| 17 | +```bash |
| 18 | +# WRONG — do not pipe: |
| 19 | +clibrowser get "https://example.com" --json | clibrowser markdown |
| 20 | + |
| 21 | +# CORRECT — run sequentially: |
| 22 | +clibrowser --stealth get "https://example.com" |
| 23 | +clibrowser markdown --max-length 3000 |
| 24 | +``` |
| 25 | + |
| 26 | +The `get` command fetches the page and caches it in the session. Then `markdown`, `text`, `select`, `links`, `tables`, and other extraction commands read from that cache. |
| 27 | + |
13 | 28 | ### Essential commands |
14 | 29 |
|
15 | 30 | | Task | Command | |
16 | 31 | |------|---------| |
17 | 32 | | Search | `clibrowser --stealth search "query" -n 5 --json` | |
18 | | -| Fetch page | `clibrowser --stealth get "https://url" --json` | |
| 33 | +| Search & go to first result | `clibrowser --stealth search "query" --lucky` | |
| 34 | +| Fetch page | `clibrowser --stealth get "https://url"` | |
19 | 35 | | Read as markdown | `clibrowser markdown --max-length 3000` | |
20 | | -| Extract text | `clibrowser text --strip --json` | |
| 36 | +| Extract text | `clibrowser text --strip` | |
21 | 37 | | Get links | `clibrowser links --absolute --json` | |
22 | 38 | | Follow link | `clibrowser click "a.selector" --json` | |
23 | 39 | | CSS query | `clibrowser select "h1, .class" --json` | |
|
26 | 42 | | Submit form | `clibrowser submit --json` | |
27 | 43 | | RSS feed | `clibrowser rss "https://feed" -n 10 --json` | |
28 | 44 | | Crawl site | `clibrowser crawl "https://url" --depth 2 --max-pages 10 --json` | |
| 45 | +| Sitemap | `clibrowser sitemap "https://site.com" --filter "docs" --json` | |
29 | 46 | | Batch URLs | `echo "url1\nurl2" \| clibrowser pipe --title --json` | |
30 | 47 |
|
| 48 | +### Typical workflow |
| 49 | + |
| 50 | +```bash |
| 51 | +# Step 1: Fetch the page |
| 52 | +clibrowser --stealth get "https://example.com/article" |
| 53 | + |
| 54 | +# Step 2: Read it (pick ONE of these) |
| 55 | +clibrowser markdown --max-length 5000 # as markdown |
| 56 | +clibrowser text --strip --max-length 3000 # as plain text |
| 57 | +clibrowser select "h1, h2, h3" --json # headings only |
| 58 | +clibrowser links --absolute --json # all links |
| 59 | +clibrowser tables --json # all tables |
| 60 | +
|
| 61 | +# Step 3: Navigate deeper |
| 62 | +clibrowser click "a.next-page" # follow a link |
| 63 | +clibrowser markdown --max-length 5000 # read the new page |
| 64 | +``` |
| 65 | +
|
31 | 66 | ### Tips |
32 | | -- Always use `--json` for parseable output |
33 | | -- Use `--stealth` for Cloudflare-protected sites |
| 67 | +- Always use `--json` when you need to parse the output programmatically |
| 68 | +- Use `--stealth` for sites with bot detection (Cloudflare, etc.) |
34 | 69 | - Use `--session name` for parallel browsing sessions |
35 | 70 | - Exit codes: 0=success, 1=app error, 2=HTTP error, 3=network error |
36 | 71 | - Every JSON response has `"ok": true/false` at top level |
| 72 | +- `get` saves the page; `text`/`markdown`/`select`/`links`/`tables` read from it |