Skip to content

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.

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:

Terminal window
pam crawl https://example.com -o md

The 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

Like crwl, you may install the command once and use it from any directory:

Terminal window
pam composer global require pushinbr/pam-crawl
export PATH="$(pam composer global config bin-dir --absolute):$PATH"
crawl https://example.com -o markdown

The 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" ....

Pass one or more URLs as arguments, read them from a file with -i (repeatable), or pipe them on stdin:

Terminal window
pam crawl https://example.com -o md
pam crawl -i urls.txt -o jsonl -O pages.jsonl
cat urls.txt | pam crawl -o jsonl --concurrency 64 > pages.jsonl
-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.

Use a content filter with -f (pruning, bm25, main, or a YAML file) together with --query and --threshold, and restrict the page with CSS:

Terminal window
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 md
pam 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.

Turn a single URL into a site crawl with --deep-crawl:

Terminal window
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.

Terminal window
# 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 schema
pam 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.

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)

-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:

Terminal window
pam crawl options

Settings are merged in this order, last wins: config files, then -b / -c pairs, then dedicated flags.

crawl seed lists URLs from a domain’s sitemaps (or Common Crawl) without fetching the pages:

Terminal window
pam crawl seed example.com --pattern '*/blog/*' -n 500
pam crawl seed example.com --source sitemap+cc -o jsonl

Options: --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:

Terminal window
pam crawl map example.com --source sitemap+cc
pam crawl map example.com -o json -O map.json

Options: --source / -s, --limit N / -n N, --query, --subdomains, -o, -O, and --max-pages (default 500) and --depth (default 5) for the fallback crawl.

crawl adaptive keeps crawling from a start URL until it has enough information to answer a query, then prints the most relevant passages:

Terminal window
pam crawl adaptive https://docs.example.com -q "rate limits" --max-pages 20
pam 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
Terminal window
pam crawl serve --port 11235 # HTTP API, one worker
pam crawl serve --workers 4 --token secret # PAM cluster with bearer auth
pam crawl mcp # MCP server on stdio

serve accepts --host, --port / -p, --workers / -w, --token, --allow-private and --cache [path]. mcp accepts --allow-private. See HTTP API and MCP Server.

Like crwl’s global settings, crawl config stores defaults that apply to every run. Flags and environment variables always win.

Terminal window
pam crawl config list
pam crawl config set CACHE_MODE use # bypass | use | refresh
pam crawl config set DEFAULT_LLM_PROVIDER ollama/qwen2.5:7b
pam crawl config set DEFAULT_LLM_PROVIDER_TOKEN env:OPENAI_API_KEY
pam crawl config get VERBOSE
pam 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.

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.

Terminal window
pam crawl https://app.example.com --render # render only pages that need JS
pam crawl https://app.example.com --render always --engine chrome
pam crawl https://example.com/login --c4a login.c4a -o md # C4A-Script
Terminal window
pam crawl --help
pam crawl examples
pam crawl --version

Set 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).