This page lists the public PHP API of pushinbr/pam-crawl 0.1. Everything lives under the
Pam\Crawl namespace. The guides explain each feature with examples; use this page to look up a
signature or find the guide you need.
Crawler builders are immutable : every method returns a modified copy, so you can configure a
crawler once and reuse it. Nothing is fetched until you call a terminal method.
Pam\Crawl\Crawl creates crawlers:
Method
Description
Crawl::url(string $url): Crawler
One page
Crawl::urls(iterable $urls): Crawler
Many pages; any iterable of URLs or Request objects, consumed lazily
Crawl::site(string ...$seeds): Crawler
Deep crawl from one or more seeds: same host, depth 3, 1000 pages, robots.txt respected, asset and nonsense URLs filtered
Crawl::html(string $html, string $baseUrl = 'about:blank'): Crawler
HTML you already have (Crawl4AI’s raw: URLs)
Crawl::defaultFilters(): list<UrlFilter>
The URL filters site() applies
Pam\Crawl\Crawler methods, grouped by purpose.
Method
Default
concurrency(int $total, ?int $perHost = null)
32 total
perHost(int $connections)
6
delay(float $seconds)
0.0
jitter(float $seconds)
0.0
timeout(float $seconds, ?float $connect = null)
20.0, connect 10.0
retries(int $retries)
2
maxBytes(int $bytes)
10 MiB
userAgent(string $userAgent)
A desktop Chrome user agent
randomUserAgent(?string $device = null, int $rotate = 1)
$device: 'desktop', 'mobile' or null
headers(array $headers), header(string $name, string $value)
cookies(array $cookies)
session(?string $cookieJarFile = null)
Persist cookies across requests (and runs, with a file)
proxy(string ...$proxies)
Rotated round-robin
insecure()
Skip TLS verification
respectRobots(bool $respect = true)
Off for url() / urls(), on for site()
post(string $body, string $contentType = 'application/x-www-form-urlencoded')
allowFiles(bool $allow = true)
Allow file:// URLs
downloads(string $directory, int $maxBytes = 512 * 1024 * 1024)
Stream non-text responses to disk
anyContentType()
Accept PDFs, images and other types
certificate(bool $capture = true)
Capture TLS certificates
curlOptions(array $options)
Raw curl options for every transfer
See Caching & Politeness .
Method
Description
cache(string|bool $path = true, ?float $ttl = null, CacheMode $mode = CacheMode::Enabled)
SQLite HTTP cache, default ./.cache/pam-crawl.sqlite, TTL 24 h; false disables
cacheMode(CacheMode $mode)
Change the mode only
withCache(Cache $cache)
Your own Pam\Crawl\Cache\Cache implementation
Method
Description
selector(string $css)
Restrict Markdown, links and media to matching elements
target(string ...$css)
Build Markdown from matching elements only
exclude(string $css), excludeTags(string ...$tags)
Remove elements before Markdown
filter(Content\Filter $filter)
Filter for $page->markdown (default none) and $page->content (default main content)
wordThreshold(int $words)
Minimum words per text block
keepForms(), withoutImages(), withoutLinks(), onlyText(bool $only = true)
Markdown shaping
excludeExternalLinks(), excludeInternalLinks(), excludeSocialLinks(), excludeDomains(string ...$domains)
Link filtering (each takes bool $exclude = true)
excludeExternalImages(), excludeAllImages()
Image filtering
keepAttributes(string ...$attributes), keepDataAttributes(bool $keep = true)
Attributes kept in cleanedHtml
See Markdown & Content .
Method
Description
depth(int $maxDepth), limit(int $maxPages)
Bounds
only(string ...$patterns), except(string ...$patterns)
Globs or regular expressions
filterUrls(UrlFilter ...$filters)
Frontier\Filter or your own UrlFilter
prioritize(Scorer $scorer, float $threshold = -INF)
Best-first crawling
strategy(Frontier\Strategy $strategy)
BreadthFirst, DepthFirst, BestFirst
scope(Frontier\Scope $scope), includeSubdomains(), followExternal()
Host (default), Domain, Anywhere
sitemap(bool $use = true)
Seed from robots.txt and sitemaps
ignoreQueryStrings()
Strip query strings when deduplicating URLs
dedupeContent(int $bits = 3)
Skip near-duplicate pages (SimHash)
See Deep Crawling & Seeding .
Method
Description
onPage(callable $hook)
Called for every page before it is yielded; Stats, Export\Jsonl and closures fit here
when(string|UrlFilter $pattern, callable $configure)
Content options for matching URLs only
retryBlocked(int $retries = 2)
Retry bot walls through the next proxy
fallback(callable $fetch)
Your own fetcher for blocked or failed pages; returns HTML or null
These need a renderer, usually the PAM Crawl Browser plugin. Without
one, browser-only features throw a RuntimeException with the install hint.
Method
Description
render(?Renderer $renderer = null, RenderMode $mode = RenderMode::Auto)
HTTP first, render only pages that need it
browser(?Renderer $renderer = null)
Render every page
engine(string $engine)
'chrome', 'lightpanda' or a CDP websocket URL
js(string ...$code), script(string $c4a, ?string $root = null)
JavaScript or C4A-Script
waitFor(string $condition, float $timeout = 30.0), waitUntil(string $event)
Waits
scrollFullPage(float $delay = 0.2, ?int $maxSteps = null)
Infinite scroll
virtualScroll(string $container, int $count = 10, string $by = 'container_height', float $wait = 0.5)
Virtualized lists
screenshot(bool $fullPage = true), capturePdf(), captureMhtml()
Captures
captureNetwork(), captureConsole()
Network and console logs
viewport(int $width, int $height, float $scale = 1.0, bool $mobile = false)
Viewport
magic(), blockResources(string ...$types)
Stealth and overlays; resource blocking
tab(string $sessionId), Crawler::closeTabs()
Persistent browser tabs
renderOptions(callable $change)
Any RenderOptions field
Method
Description
workers(int $workers = 0)
Worker processes for map(); 0 = one per CPU core
See Performance & Workers .
Method
Returns
get(): Page
The first page; throws when there is nothing to crawl
stream(): Generator<Page>
Pages in completion order (also foreach ($crawler as $page))
each(callable $callback): int
Page count; return false from the callback to stop
all(): list<Page>
Every page in memory
map(callable $fn, ?int $workers = null, int $batch = 64): Generator
Your callback’s results, optionally from worker processes
markdown(bool $fit = false): string
Markdown of the first page
extract(string $class): ?object
One DTO from the first page
extractAll(string $class, ?string $each = null): list<object>
DTOs from every page
options(): Options
The effective configuration
Pam\Crawl\Page is one crawled page. Everything derived from the HTML is computed on first
access and memoized.
Property
Type
url, finalUrl
string
status
int
ok, blocked, isShell, fromCache, rendered, duplicate
bool
error
?string
headers
array<string, list<string>>
html
string, the raw body
depth, parent, elapsed
Crawl position and timing
response
The underlying Fetch\Response (including renderer artifacts)
Property or method
Type
markdown
Markdown\Markdown with raw, withCitations, references
content
Markdown\Markdown, main content only (fit Markdown)
markdown(?string $focus = null, bool $citations = false, ?Filter $filter = null): string
Focused or cited Markdown
text, cleanedHtml, wordCount, simhash
Plain text, cleaned HTML, counts, near-duplicate hash
document
The parsed Dom\HTMLDocument
select(string $selector): array, first(string $selector): ?Element
CSS queries
Property or method
Type
meta
Result\Meta: title, description, canonical, lang, OpenGraph, Twitter, feeds…
links
Result\Links with internal, external, urls(), matching()
images, videos, audios
list<Result\Media>
tables
list<Result\Table> with toCsv() and toMarkdown()
jsonLd, embedded
JSON-LD blocks; hydration data (Next.js, Nuxt, Remix, Apollo…)
json, feed, pdf, file, certificate
JSON body, RSS/Atom feed, PDF reader, downloaded file, TLS certificate
api(bool $verify = true): array
JSON APIs discovered behind the page
extract(string $class), extractAll(string $class, ?string $each = null)
DTO extraction
free(): void
Release the DOM and derived caches
toArray(bool $full = false): array
Crawl4AI-shaped result array (also json_encode($page))
Filled when a renderer was used: screenshot (PNG bytes), pdfBytes, mhtml, network,
console and jsResults.
Class
Purpose
Guide
Content\Bm25Filter, Content\PruningFilter, Content\MainContentFilter
Content filters
Markdown & Content
Frontier\Filter, Frontier\Score
URL filters and scorers
Deep Crawling & Seeding
Seed\UrlSeeder, Seed\DomainMapper
URL discovery
Deep Crawling & Seeding
Adaptive\AdaptiveCrawler, Adaptive\Config
Crawl until a query is answered
Deep Crawling & Seeding
Extract\Css, Extract\JsonLd, Extract\Item, Extract\Schema, Extract\RegexExtractor
Extraction
Extraction
Llm\Config, Llm\LlmExtraction, Llm\Ask, Llm\Embeddings
LLM features
LLM Features
Script\C4a
Compile C4A-Script
JavaScript Pages
Hub\Hub
Named, reusable crawlers
Extraction
Stats
Live statistics with constant memory
Caching & Politeness
Export\Jsonl, Export\Csv
Write pages or rows as JSON lines or CSV
Watch\Watcher, Watch\Diff
Change monitoring with line diffs
Parallel\Pool
The process pool behind map()
Performance & Workers
Export\Jsonl is an onPage() hook that appends one JSON object per page; Export\Csv::write()
writes rows (or DTOs) to a CSV file and returns the row count:
use Pam \ Crawl \ Export \ Csv ;
use Pam \ Crawl \ Export \ Jsonl ;
$quotes = Crawl :: urls ($urls)
-> onPage ( new Jsonl ( 'pages.jsonl' , fn ( Page $p) : array => [ 'url' => $p -> url, 'title' => $p -> meta -> title]))
-> extractAll ( Quote :: class );
Csv :: write ( 'quotes.csv' , $quotes);
Watch\Watcher re-crawls pages, compares their main content with the previous run (stored in
SQLite) and yields a Diff per page:
use Pam \ Crawl \ Watch \ Diff ;
use Pam \ Crawl \ Watch \ Watcher ;
$watcher = new Watcher ( Crawl :: urls ([ 'https://example.com/pricing' ]) -> cache (false));
foreach ($watcher -> check () as $diff) {
if ( ! $diff -> firstSeen && $diff -> changed ()) {
echo $diff -> summary (), " \n " ;
// In a long-running worker:
$watcher -> every ( 3600 , fn ( Diff $d) => notify ($d -> summary ()));
Enum
Cases
Cache\CacheMode
Enabled, Disabled, ReadOnly, WriteOnly, Bypass
Render\RenderMode
Never, Auto, Always
Frontier\Strategy
BreadthFirst, DepthFirst, BestFirst
Frontier\Scope
Host, Domain, Anywhere
Interface
Implement it to
Cache\Cache
Store responses elsewhere: get(), put(), touch()
Render\Renderer
Plug in your own JavaScript renderer: render(array $requests, RenderOptions $options): iterable and close()
Frontier\UrlFilter, Frontier\Scorer
Custom deep-crawl filters and scorers
Content\Filter
Custom content filters
This product includes software developed by UncleCode (https://x.com/unclecode ) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai ).