PAM Crawl Browser
PAM Crawl reads most of the web without a browser: server-rendered pages,
hydration data and the JSON APIs behind apps. pushinbr/pam-crawl-browser covers the rest:
pages that only exist after JavaScript runs, and everything that needs a real browser, such as
screenshots, PDFs, clicks and logins.
It is a plugin, not a new API. Once installed, the crawler you already use gains render(),
browser(), js(), waitFor(), screenshot() and friends:
- Only when needed.
->render()fetches over HTTP first and opens a browser only for app shells, bot walls and hosts it has learned need JavaScript. - Lightweight by default. Lightpanda renders single-page apps with a fraction of Chrome’s memory; Chrome steps in for screenshots, PDF and MHTML.
- Crawl4AI browser parity.
js_code,wait_for, full-page and virtual scroll, iframes and shadow DOM, consent and overlay removal, stealth, sessions, profiles, network and console capture, downloads and C4A-Script. - One PHP thread. It drives browsers over the Chrome DevTools Protocol (through
pushinbr/pam-browser) with no Node.js and no extensions beyondjsonanddom.
Installation
Section titled “Installation”Requirements
Section titled “Requirements”- PHP 8.5 on the PAM runtime (or plain PHP 8.5)
pushinbr/pam-crawl0.1.3 or later (installed automatically)- Google Chrome or Chromium, and optionally Lightpanda
- Optional: the
gdextension, to stitch very tall full-page screenshots into one PNG
Installing The Package
Section titled “Installing The Package”mkdir my-crawler && cd my-crawlerpam composer init --no-interactionpam composer require pushinbr/pam-crawl pushinbr/pam-crawl-browserInstalling A Browser
Section titled “Installing A Browser”Install Google Chrome or Chromium with your system’s package manager. The plugin looks for it,
in order, at /usr/bin/google-chrome, in Playwright’s Chromium download, and on your PATH.
Point it anywhere else with the PAM_CRAWL_CHROME environment variable:
export PAM_CRAWL_CHROME=/opt/chromium/chromeDownload the Lightpanda binary for your platform from lightpanda.io
and place it at ~/.local/share/pam-crawl/bin/lightpanda (or on your PATH):
mkdir -p ~/.local/share/pam-crawl/binmv lightpanda ~/.local/share/pam-crawl/bin/lightpandachmod +x ~/.local/share/pam-crawl/bin/lightpandaUse PAM_CRAWL_LIGHTPANDA for any other location. When Lightpanda is installed, the auto
engine prefers it and falls back to Chrome for features Lightpanda lacks.
Configuration
Section titled “Configuration”Most settings are crawler methods, so there is nothing to configure up front. The plugin reads these environment variables:
| Variable | Purpose |
|---|---|
PAM_CRAWL_CHROME |
Path to the Chrome or Chromium binary |
PAM_CRAWL_LIGHTPANDA |
Path to the Lightpanda binary |
PAM_CRAWL_SOFTWARE_GL=1 |
Turn off GPU rendering in Chrome, for machines without a GPU |
Chrome runs on the GPU by default (ANGLE over EGL, never SwiftShader). On servers and containers
without a GPU, set PAM_CRAWL_SOFTWARE_GL=1. For full control, create the renderer yourself with a
BrowserConfig; see Engines.
Your First Render
Section titled “Your First Render”<?php
declare(strict_types=1);
require __DIR__.'/vendor/autoload.php';
use Pam\Crawl\Crawl;
// 1. Auto mode: plain HTTP first, a browser only for pages that need JavaScript$page = Crawl::url('https://quotes.toscrape.com/js/')->render()->get();echo $page->rendered ? "rendered in a browser\n" : "plain HTTP was enough\n";echo $page->content->raw, "\n\n";
// 2. Always render, wait for an element, run JavaScript, capture a screenshot and a PDF$page = Crawl::url('https://quotes.toscrape.com/js/') ->browser() ->waitFor('css:div.quote', 10) ->js('return document.querySelectorAll("div.quote").length') ->screenshot() ->capturePdf() ->get();
printf("%d quotes\n", $page->jsResults[0]);file_put_contents('quotes.png', $page->screenshot);file_put_contents('quotes.pdf', $page->pdfBytes);pam render.phpThe first request is an app shell, so render() opens a browser for it; a server-rendered page
such as https://quotes.toscrape.com/ would stay on plain HTTP. Browsers start lazily on first
use and stop when the script ends.
From the command line, --render does the same:
pam crawl https://quotes.toscrape.com/js/ --render -o md-fitpam crawl https://app.example.com --render always --engine chromeChoosing A Mode
Section titled “Choosing A Mode”| Method | Behaviour | Use it when |
|---|---|---|
->render() |
HTTP first; render app shells, bot walls and hosts learned to need it | Crawling a mix of pages (recommended) |
->browser() |
Render every page (Crawl4AI’s default) | Every page needs JavaScript, or you need captures |
| Browser-only methods | js(), waitFor(), screenshot(), capturePdf()… imply rendering |
You need the browser for that page |
render() and browser() also accept your own renderer instance, and render() takes a
RenderMode (Never, Auto, Always) as its second argument.
Next Steps
Section titled “Next Steps”- Rendering & Interaction: waits, scripts, scrolling, captures and logged-in tabs
- Engines: Chrome, Lightpanda and remote browsers
- Browser CLI: the builtin browser and profiles
- Options Reference: every option, mapped to Crawl4AI
Responsible Use
Section titled “Responsible Use”Rendering costs the sites you visit more than plain HTTP: it loads their scripts, styles and
images. Prefer ->render() over ->browser(), keep tab counts and per-host concurrency polite,
respect robots.txt and each site’s terms of service, and never use stealth features to bypass
access controls. Read Responsible Use.
This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).