Skip to content

Browser CLI

The plugin adds Crawl4AI’s browser commands to the crawl CLI: a persistent builtin browser that many crawls can share, a standalone CDP browser, and browser profiles for crawling as a logged-in user. They run through the core command, as pam crawl ... in a PAM project or pam vendor/bin/crawl ... elsewhere. Without the plugin, these commands print an install hint and exit with 2.

Terminal window
pam crawl https://app.example.com --render # only pages that need JavaScript
pam crawl https://app.example.com --render always # every page
pam crawl https://app.example.com --render always --engine lightpanda
pam crawl https://app.example.com --render always --no-headless # watch the browser
pam crawl https://example.com/login --c4a login.c4a -o md # C4A-Script
Option Description
--render [auto|always] Turn rendering on; auto when no value is given
--engine auto|chrome|lightpanda Engine selection
--cdp URL|builtin Render through a CDP endpoint, or the builtin browser
-p NAME, --profile NAME Use a saved browser profile
--[no-]headless Show or hide the browser window
--c4a file.c4a Run a C4A-Script file in the page

Crawl4AI-style -b settings work too: -b browser_mode=builtin, cdp_url=..., user_data_dir=..., headless=false and browser_type=....

The builtin browser is a persistent Chrome with CDP enabled. Start it once and point crawls at it, so they skip the browser start-up and share its cookies:

Terminal window
pam crawl browser start [--port 9222] [--no-headless]
pam crawl browser status [--json] # PID, port, ws:// URL, profile directory
pam crawl browser view [--url URL] [--open] # CDP and DevTools URLs, open tabs
pam crawl browser restart [--port N]
pam crawl browser stop
pam crawl https://example.com --cdp builtin -o md

It runs detached, in its own session, with the profile ~/.local/share/pam-crawl/builtin-browser/user-data, and records its PID, port and websocket URL in state.json next to it. view --url opens a new tab at that URL; view --open shows a viewer window with the tab list.

stop closes the browser over CDP and, if needed, signals only the saved PID, after checking that the process is still Chrome running on that profile. A stale or reused PID is never signalled.

crawl cdp starts a Chrome with CDP enabled in the foreground, for your own tools or for another crawler to connect to:

Terminal window
pam crawl cdp [--port 9222] [-d DIR] [--headless] [--incognito] [--url URL]

It uses a temporary profile unless you pass -d DIR (--user-data-dir), and stops exactly the Chrome it launched when you press Enter or q, on Ctrl-C or SIGTERM, or when you close the window.

A profile is a Chrome user data directory with your cookies and storage. Create one by logging in by hand, then crawl as that user:

Terminal window
pam crawl profiles create work [--url https://login.example.com] # a visible Chrome opens: log in, press Enter
pam crawl profiles list
pam crawl https://example.com/account --profile work -o md
pam crawl profiles delete work [--force]

Profiles live in ~/.local/share/pam-crawl/profiles/<name> ($XDG_DATA_HOME is respected). create also saves a portable storage_state.json with the profile’s cookies, like Crawl4AI. Profiles that are open in a browser are never deleted or shrunk.

In PHP, use a profile through the userDataDir render option or BrowserConfig::$userDataDir:

Crawl::url('https://example.com/account')
->renderOptions(fn ($o) => $o->with(['userDataDir' => getenv('HOME').'/.local/share/pam-crawl/profiles/work']))
->get();

Profiles grow with caches and history. shrink keeps exactly what Crawl4AI keeps at each level (cookies, local storage, IndexedDB, preferences…) and deletes the rest:

Terminal window
pam crawl shrink work --level aggressive --dry-run # light | medium | aggressive | minimal
pam crawl shrink work --level aggressive

--dry-run only reports what would be deleted.


This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).