Skip to content

Quick start

All Brimp interfaces navigate through the same runtime. Pick the one that fits your application.

import brimp
response = brimp.get("https://example.com")
response.raise_for_status()
print(response.status_code)
print(response.html) # DOM serialized after page scripts run

Use a session when you need cookies, repeated navigation, evaluation, or a screenshot:

import brimp
with brimp.Session() as session:
response = session.get("https://example.com", timeout=30)
print(session.evaluate("document.title"))
session.screenshot("example.png", full_page=True)
const { launch } = require('@brimp/brimp')
async function main() {
const browser = await launch()
const page = await browser.newPage()
await page.goto('https://example.com')
console.log(await page.title())
await page.close()
await browser.close()
}
main().catch(error => {
console.error(error)
process.exitCode = 1
})

Evaluate JavaScript after navigation:

Terminal window
brimp eval https://example.com --js 'document.title'

Capture a full-page screenshot:

Terminal window
brimp screenshot https://example.com \
--output example.png \
--full-page

Start Brimp’s loopback CDP server:

Terminal window
brimp cdp --bind 127.0.0.1:9222

Then connect with puppeteer-core:

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')
console.log(await page.evaluate(() => document.title))
await browser.disconnect()

The CDP server supports a checked protocol subset. Consult the CDP API reference before adapting a larger Puppeteer workflow.