CLI and CDP examples
Check native dependencies
Section titled “Check native dependencies”brimp doctorSuccessful output is JSON suitable for scripts:
{"javascriptCore":"ok","libcurlImpersonate":"ok","profile":"chrome150"}Extract structured data
Section titled “Extract structured data”brimp eval prints the evaluated JSON value to standard output and diagnostics
to standard error:
brimp eval https://example.com \ --js '({title: document.title, links: document.querySelectorAll("a").length})'Set a navigation timeout in milliseconds when the 30-second default is not appropriate:
brimp eval https://example.com \ --timeout-ms 10000 \ --js 'document.body.textContent.trim()'Use a persona
Section titled “Use a persona”brimp eval https://example.com \ --persona persona/example.json \ --js '({ua: navigator.userAgent, platform: navigator.platform})'Protect screenshot output
Section titled “Protect screenshot output”brimp screenshot https://example.com \ --output example.png \ --full-pageBrimp refuses to replace an existing file unless --overwrite is explicit.
Connect Puppeteer
Section titled “Connect Puppeteer”Start the server on its loopback default:
brimp cdpThe first output line is the browser WebSocket endpoint. Puppeteer can discover it through the HTTP endpoint:
const fs = require('node:fs/promises')const puppeteer = require('puppeteer-core')
const browser = await puppeteer.connect({ browserURL: 'http://127.0.0.1:9222',})
const [page] = await browser.pages()await page.goto('https://example.com')
const result = await page.evaluate(() => ({ title: document.title, answer: 6 * 7,}))const png = await page.screenshot()
console.log(result)await fs.writeFile('example.png', png)await browser.disconnect()Do not expose the server to a network unless you intend to give every reachable
client control of the browser. Non-loopback binds require
--allow-non-loopback and print a security warning.