Skip to main content

Lightning-fast web scraping Python SDK - 11x faster than traditional scrapers

Project description

browsernative

Python client for the Browser Native web scraping API

PyPI Python License

Lightweight client for scraping, screenshots, and AI analysis via the Browser Native API. Single dependency (requests).

Install

pip install browsernative

Get an API key at bnca.monostate.ai.

Usage

from browsernative import BrowserNativeClient

client = BrowserNativeClient('your-api-key')

# Scrape
result = client.scrape('https://example.com')

# Force a specific scraping method
result = client.scrape('https://example.com', method='lightpanda')

# Screenshot
screenshot = client.screenshot('https://example.com')

# Quick screenshot (faster, no content extraction)
quick = client.quickshot('https://example.com')

# AI Q&A
answer = client.analyze('https://example.com', 'What is this site about?')

Convenience functions

from browsernative import quick_scrape, quick_shot, quick_analyze, bulk_scrape

content = quick_scrape('https://example.com', 'your-api-key')
shot = quick_shot('https://example.com', 'your-api-key')
answer = quick_analyze('https://example.com', 'What is this?', 'your-api-key')

Bulk scraping

urls = ['https://site1.com', 'https://site2.com', 'https://site3.com']

result = client.bulk_scrape(
    urls,
    concurrency=5,
    continue_on_error=True,
    progress_callback=lambda p: print(f"{p['percentage']:.1f}%"),
)

print(f"{result['stats']['successful']}/{result['stats']['total']} succeeded")

Context manager

with BrowserNativeClient('your-api-key') as client:
    result = client.scrape('https://example.com')
    # Session closed automatically

API Reference

Client options

client = BrowserNativeClient(
    api_key='your-api-key',
    base_url='https://bnca-api.fly.dev',  # API endpoint
    timeout=30,                            # Seconds
    retries=2,                             # Retry attempts
    verbose=False,                         # Debug logging
)

Methods

Method Description
scrape(url, **opts) Extract structured content
screenshot(url, **opts) Screenshot with content extraction
quickshot(url, **opts) Fast screenshot only
analyze(url, question, **opts) AI-powered Q&A
bulk_scrape(urls, **opts) Scrape multiple URLs concurrently
get_usage(days=30) Account usage statistics
health_check() API health status

Scrape options

Pass as keyword arguments:

  • method -- 'auto', 'direct', 'lightpanda', or 'puppeteer'
  • include_screenshot -- Include screenshot in response
  • wait_for_selector -- CSS selector to wait for
  • user_agent -- Custom user agent

Response shape

{
    'success': True,
    'data': { 'title': ..., 'content': ..., ... },
    'responseTime': 1234,
    'attempt': 1,
}

Browser sessions

Persistent browser sessions with real-time control over WebSocket:

session = client.create_session(mode='auto')

session.goto('https://example.com')
session.click('#login')
session.type('#email', 'user@example.com')
state = session.get_page_state(includeScreenshot=True)
session.screenshot()

# Listen for backend fallback events
session.on('fallback', lambda e: print(f"{e['from']} -> {e['to']}: {e['reason']}"))

session.close()

Modes: auto (LightPanda + Chrome fallback), headless, visual, computer-use.

Computer use mode

For AI agents that control the browser by pixel coordinates:

session = client.create_session(mode='computer-use', screen_width=1280, screen_height=800)

session.goto('https://example.com')
session.click_at(640, 400)
session.type_text('hello world')
session.mouse_move(100, 200)
session.drag(10, 20, 300, 400)
session.scroll_at(640, 400, 'down', 5)
pos = session.get_cursor_position()
size = session.get_screen_size()
screenshot = session.screenshot()

# VNC streaming URL
print(session.vnc_url)

session.close()

Requires websocket-client: pip install websocket-client

Requirements

  • Python 3.9+
  • requests (installed automatically)
  • websocket-client (for browser sessions)

Changelog

See CHANGELOG.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browsernative-2.2.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

browsernative-2.2.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file browsernative-2.2.0.tar.gz.

File metadata

  • Download URL: browsernative-2.2.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for browsernative-2.2.0.tar.gz
Algorithm Hash digest
SHA256 ca1d068123bb75016c8d443938bf393d0527b16033156d0618daa08cdc010518
MD5 6946fbbe3d83c79399e61a19646bcb93
BLAKE2b-256 85fef7708c7b218c1e713ba9a3bfb41f539e2341b4522dbc85d603f9e09bdac2

See more details on using hashes here.

File details

Details for the file browsernative-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: browsernative-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for browsernative-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f453a47a0257674e0bd53ad4d60b906472cf5fd22d5b8a78f91a6f2c03c339c1
MD5 3a5b28246707f84a4c2e96f576fc25e3
BLAKE2b-256 bb61361af00e2803cab5cc072bca11969593ee1665456d41a1e83e8912525721

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page