Command Line
PAM Crawl ships a crawl command that mirrors Crawl4AI’s crwl. It turns one URL, a list of
URLs or a whole site into Markdown or JSON, extracts structured data, discovers URLs and
starts the HTTP API or the MCP server.
Everything the CLI does is also available from PHP, so you can prototype on the command line
and move the same options into code later.
Running The Command
Section titled “Running The Command”How you invoke the command depends on where you are:
Inside a PAM project (a directory with a pam.json manifest, for example one created by
pam init), the package registers a crawl command with PAM:
pam crawl https://example.com -o mdIn any project that requires pushinbr/pam-crawl, run the Composer binary through PAM:
pam vendor/bin/crawl https://example.com -o mdThe CLI also runs on plain PHP 8.5 with ext-curl, ext-dom and ext-mbstring:
php vendor/bin/crawl https://example.com -o mdThe examples on this page use pam crawl; substitute pam vendor/bin/crawl when you are not
in a PAM project. Data goes to stdout, while progress (-v) and errors go to stderr, so you can
pipe the output safely.
| Exit code | Meaning |
|---|---|
0 |
Success |
1 |
The crawl failed (or returned nothing) |
2 |
Usage error, or a browser command without the browser plugin |
Installing The Command Globally
Section titled “Installing The Command Globally”Like crwl, you may install the command once and use it from any directory:
pam composer global require pushinbr/pam-crawlexport PATH="$(pam composer global config bin-dir --absolute):$PATH"
crawl https://example.com -o markdownThe script starts with #!/usr/bin/env pam, so it runs on PAM. Without PAM, call it through
PHP: php "$(composer global config bin-dir --absolute)/crawl" ....
Crawling Pages
Section titled “Crawling Pages”Pass one or more URLs as arguments, read them from a file with -i (repeatable), or pipe them
on stdin:
pam crawl https://example.com -o mdpam crawl -i urls.txt -o jsonl -O pages.jsonlcat urls.txt | pam crawl -o jsonl --concurrency 64 > pages.jsonlOutput Formats
Section titled “Output Formats”-o value |
Output |
|---|---|
all (default) |
Crawl4AI-style result objects as JSON |
json |
JSON |
jsonl |
One JSON object per page, streamed as pages complete |
markdown, md |
Full-page Markdown |
markdown-fit, md-fit |
Main content only (Crawl4AI’s fit_markdown) |
Write to a file with -O file. Add --include-html to include the HTML in JSON output,
--citations for numbered link citations in Markdown, and --json-ensure-ascii to escape
non-ASCII characters.
Focusing The Content
Section titled “Focusing The Content”Use a content filter with -f (pruning, bm25, main, or a YAML file) together with
--query and --threshold, and restrict the page with CSS:
pam crawl https://docs.example.com -o md-fit -f bm25 --query "rate limits"pam crawl https://example.com --selector "main" --exclude "nav, footer" -o mdpam crawl https://example.com --target "article" -o md--selector restricts everything (Markdown, links and media) to the matching elements, while
--target builds Markdown from the matching elements only and keeps links and media from the
whole page. See Markdown & Content for what each filter does.
Deep Crawls
Section titled “Deep Crawls”Turn a single URL into a site crawl with --deep-crawl:
pam crawl https://docs.example.com --deep-crawl bfs --max-pages 50 \ --only '/docs/*' --except '*/changelog/*' -o jsonl -O docs.jsonl -v| Option | Description |
|---|---|
--deep-crawl bfs|dfs|best-first |
Crawl strategy. --max-pages defaults to 10 when a strategy is set. |
--max-pages N |
Maximum number of pages |
--depth N, -d N |
Maximum link depth |
--only GLOB, --except GLOB |
Follow only, or never follow, matching URLs (repeatable) |
-k keyword |
Score links by keyword; implies best-first (repeatable) |
--sitemap |
Also seed the crawl from robots.txt and sitemap.xml |
--robots |
Respect robots.txt |
Read Deep Crawling & Seeding for strategies, filters and scorers.
Extracting Data
Section titled “Extracting Data”# Hydrate your own DTO class (autoloaded from ./vendor/autoload.php)pam crawl https://news.example.com --extract-class 'App\Story' -o json
# A Crawl4AI CSS/XPath JSON schemapam crawl https://shop.example.com -s schema.json -o json
# Ask an LLM a question about the page (needs an LLM provider)pam crawl https://example.com -q "What is this page about?"--extract-class loads the current project’s autoloader, so your own classes are found; use
--autoload file.php to load another file and --each CSS to extract one item per matching
element. -e extract.yml takes a Crawl4AI-style extraction config and -j [instruction]
runs LLM extraction. See Extraction and
LLM Features.
Transport Options
Section titled “Transport Options”| Option | Description |
|---|---|
-H 'Name: value' |
Extra request header (repeatable) |
-A user-agent, --random-ua |
Fixed or rotating realistic user agent |
--proxy URL |
Proxy, repeatable for round-robin rotation |
--timeout S, --concurrency N, --jitter S |
Timeouts, parallel requests, random extra delay per host |
--retry-blocked |
Retry pages blocked by a bot wall through the next proxy |
--dedupe |
Skip near-duplicate pages |
--session [cookies.json] |
Keep cookies across requests (and runs, with a file) |
--downloads DIR |
Stream non-HTML responses to a directory |
--cache [path], --bypass-cache / -bc |
HTTP cache (default .cache/pam-crawl.sqlite) |
Crawl4AI-Style Configuration
Section titled “Crawl4AI-Style Configuration”-c key=value,... accepts PAM Crawl option names and Crawl4AI CrawlerRunConfig /
BrowserConfig names such as css_selector, page_timeout and cache_mode. -b does the
same for browser settings, and -C / -B / -e / -f accept crwl-style YAML or JSON
files. List every accepted key with:
pam crawl optionsSettings are merged in this order, last wins: config files, then -b / -c pairs, then
dedicated flags.
Seeding And Mapping Domains
Section titled “Seeding And Mapping Domains”crawl seed lists URLs from a domain’s sitemaps (or Common Crawl) without fetching the pages:
pam crawl seed example.com --pattern '*/blog/*' -n 500pam crawl seed example.com --source sitemap+cc -o jsonlOptions: --limit N / -n N (default 1000), --pattern GLOB / -p, --source,
--query, -o txt|json|jsonl and -O file.
crawl map builds a whole-domain URL map:
pam crawl map example.com --source sitemap+ccpam crawl map example.com -o json -O map.jsonOptions: --source / -s, --limit N / -n N, --query, --subdomains, -o, -O, and
--max-pages (default 500) and --depth (default 5) for the fallback crawl.
Adaptive Crawling
Section titled “Adaptive Crawling”crawl adaptive keeps crawling from a start URL until it has enough information to answer a
query, then prints the most relevant passages:
pam crawl adaptive https://docs.example.com -q "rate limits" --max-pages 20pam crawl adaptive https://docs.example.com -q "rate limits" \ --strategy embedding --llm ollama/qwen2.5:3b| Option | Default | Description |
|---|---|---|
-q query |
required | What you want to learn |
--max-pages N |
20 |
Page budget |
--depth N |
5 |
Maximum depth |
--confidence C |
0.7 |
Stop once confidence reaches this value |
--top-k N, -k N |
3 |
Passages to print |
--strategy |
statistical |
statistical or embedding |
--embedding-model |
ollama/nomic-embed-text |
Embedding model (or CRAWL_EMBEDDING_PROVIDER) |
--llm |
LLM used to expand the query in the embedding strategy | |
-o md|json, -O file, --export file |
md |
Output, output file, knowledge base export |
Servers
Section titled “Servers”pam crawl serve --port 11235 # HTTP API, one workerpam crawl serve --workers 4 --token secret # PAM cluster with bearer authpam crawl mcp # MCP server on stdioserve accepts --host, --port / -p, --workers / -w, --token, --allow-private
and --cache [path]. mcp accepts --allow-private. See HTTP API
and MCP Server.
Persistent Settings
Section titled “Persistent Settings”Like crwl’s global settings, crawl config stores defaults that apply to every run. Flags
and environment variables always win.
pam crawl config listpam crawl config set CACHE_MODE use # bypass | use | refreshpam crawl config set DEFAULT_LLM_PROVIDER ollama/qwen2.5:7bpam crawl config set DEFAULT_LLM_PROVIDER_TOKEN env:OPENAI_API_KEYpam crawl config get VERBOSEpam crawl config unset USER_AGENT_MODE| Key | Values |
|---|---|
DEFAULT_LLM_PROVIDER |
company/model, for example openai/gpt-4o-mini or ollama/qwen2.5:7b |
DEFAULT_LLM_PROVIDER_TOKEN |
API token; prefer a reference such as env:OPENAI_API_KEY |
VERBOSE |
true / false |
BROWSER_HEADLESS |
true / false |
BROWSER_TYPE |
auto, chromium or lightpanda |
CACHE_MODE |
bypass, use or refresh |
USER_AGENT_MODE |
default, random or mobile |
JSON_ENSURE_ASCII |
true / false |
The file lives at $XDG_CONFIG_HOME/pam-crawl/config.json (usually
~/.config/pam-crawl/config.json) with mode 0600. Set CRAWL_CONFIG_FILE to use another path.
Browser Commands
Section titled “Browser Commands”The browser, cdp, profiles and shrink commands, and the --render, --engine,
--profile, --cdp, --[no-]headless and --c4a options, are implemented by the
PAM Crawl Browser plugin. Without it they print an install hint and
exit with 2. See Browser CLI.
pam crawl https://app.example.com --render # render only pages that need JSpam crawl https://app.example.com --render always --engine chromepam crawl https://example.com/login --c4a login.c4a -o md # C4A-ScriptHelp And Examples
Section titled “Help And Examples”pam crawl --helppam crawl examplespam crawl --versionSet CRAWL_DEBUG=1 to print the full stack trace of an error.
This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).