Skip to main content

B4n1Web Python SDK

PyPI version License Python 3.8+

Ultra-lightweight agentic browser engine with bundled binary. Navigate URLs, extract structured content (markdown, links, screenshots), and build AI agent workflows.

Install

pip install b4n1-web

No additional binary installation needed — the SDK bundles the b4n1web binary.

Quick Start

from b4n1web import AgentBrowser, BrowserMode

# Light mode - fastest
browser = AgentBrowser(mode=BrowserMode.LIGHT)
page = browser.goto("https://example.com")
print(page.markdown)
print(f"Found {len(page.links)} links")
browser.close()

# JS mode - extract scripts
browser = AgentBrowser(mode=BrowserMode.JS)
page = browser.goto("https://example.com")
browser.close()

# Render mode - full Chromium (requires chromium install)
# browser = AgentBrowser(mode=BrowserMode.RENDER)
# page = browser.goto("https://example.com")
# print(page.screenshot)  # base64 screenshot

Context Manager

with AgentBrowser() as browser:
    page = browser.goto("https://example.com")
    print(page.markdown)

Page Object

page.url          # str: final URL
page.markdown     # str: page content as markdown
page.links        # list[str]: all links on page
page.screenshot   # str|None: base64 screenshot (render mode)

page.get_main_content()           # str: content without headers
page.find_links_by_text("more")   # list[str]: links containing "more"

Browser Modes

Mode Description RAM Startup
LIGHT HTTP fetch + HTML parsing ~15MB Instant
JS Light + JavaScript extraction ~15MB Instant
RENDER Full Chromium + screenshots ~100MB ~2s

Security

from b4n1web.security import SecurityShield

shield = SecurityShield()
shield.mark_domain("evil.com", is_safe=False)
is_safe, needs_api = shield.is_url_safe("https://evil.com/page")
# (False, False)

MCP Integration

from b4n1web.mcp import AsyncMcpClient

async with AsyncMcpClient() as client:
    page = await client.goto("https://example.com")
    print(page.markdown)

Start MCP server:

b4n1web mcp -p 8080

Error Handling

from b4n1web import BinaryNotFoundError

try:
    browser = AgentBrowser()
except BinaryNotFoundError:
    print("b4n1web binary not found. Install with:")
    print("  curl -sL https://b4n1.com/install | bash")

Version

SDK version: 0.14.0 Bundled binary version: 0.14.0


Built by B4N1 with ❤️ · All rights reserved.

Metadata

Release files for b4n1-web 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for b4n1-web 0.14.0
File Interpreter ABI Platform Actions
b4n1_web-0.14.0-py3-none-any.whl Python 3 none any Details for b4n1_web-0.14.0-py3-none-any.whl

Release files / b4n1_web-0.14.0-py3-none-any.whl

Download URL b4n1_web-0.14.0-py3-none-any.whl
Size 28.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9d512fefb7d7080de1b5ff9277b8bda85f638e6534f9a7e9e9ba35d4b32216ae
BLAKE2b-256 checksum
How to use checksums
6e6bc7b9b6f8ed210bbae619ea13a77a0cd2d785cb160d8e5602c97ad4907226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for b4n1-web 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page