Python examples
Read rendered content
Section titled “Read rendered content”Response.text is the original HTTP response text. Response.html is the live
DOM serialized after scripts execute.
import brimp
response = brimp.get("https://example.com")response.raise_for_status()
print("original bytes:", len(response.content))print("rendered HTML:", response.html)For JSON responses, use the familiar json() helper:
data = brimp.get("https://api.example.com/status").json()print(data)Query parameters and headers
Section titled “Query parameters and headers”import brimp
with brimp.Session() as session: session.headers["X-Client"] = "brimp-example" response = session.get( "https://example.com/search", params={"q": "headless browser", "tag": ["agents", "javascript"]}, headers={"X-Request-ID": "example-1"}, ) print(response.url)User-Agent and Accept-Language belong to the browser persona and cannot be
overridden as arbitrary request headers.
Keep cookies between navigations
Section titled “Keep cookies between navigations”import brimp
with brimp.Session() as session: session.cookies["experiment"] = "rendered" session.get("https://example.com/first") second = session.get("https://example.com/second") print(session.cookies) print(second.cookies)Evaluate and capture a screenshot
Section titled “Evaluate and capture a screenshot”from pathlib import Pathimport brimp
with brimp.Session() as session: session.get("https://example.com") summary = session.evaluate(""" ({ title: document.title, links: document.querySelectorAll('a').length, text: document.body.textContent.trim() }) """) png = session.screenshot(full_page=True)
print(summary)Path("example.png").write_bytes(png)Evaluation results must be JSON-compatible.
Load a persona
Section titled “Load a persona”from pathlib import Pathimport brimp
persona_json = Path("persona/example.json").read_text()
with brimp.Session(persona_json=persona_json) as session: session.get("https://example.com") print(session.evaluate("navigator.userAgent"))See the Python API for the complete public surface.