Lightning-fast web scraping Python SDK - 11x faster than traditional scrapers
Official Python client for the Browser Native web scraping API. Extract content, take screenshots, and analyze websites with AI - all with intelligent fallback mechanisms.
pip install browsernativefrom browsernative import BrowserNativeClient
# Initialize client
client = BrowserNativeClient('your-api-key')
# Scrape a webpage
result = client.scrape('https://example.com')
print(result['data']) # Extracted content
# Take a screenshot
screenshot = client.screenshot('https://example.com')
print(screenshot['data']['screenshot']) # Base64 image
# AI-powered Q&A
answer = client.analyze('https://example.com', 'What is this website about?')
print(answer['data']['answer']) # AI responsefrom browsernative import quick_scrape, quick_analyze, quick_shot
# Quick scraping
data = quick_scrape('https://example.com', 'your-api-key')
# Quick AI analysis
result = quick_analyze(
'https://example.com',
'What services do they offer?',
'your-api-key'
)
# Quick screenshot
screenshot = quick_shot('https://example.com', 'your-api-key')- π Lightning Fast: 11x faster than traditional scrapers
- π Intelligent Fallback: Multi-tier system (Direct β Lightpanda β Puppeteer)
- π€ AI Integration: Built-in Q&A capabilities with OpenRouter/OpenAI
- πΈ Screenshots: Full page captures with optimization
- π PDF Support: Automatic PDF parsing and text extraction
- π Type Safe: Full type hints for better IDE support
- β»οΈ Context Manager: Automatic resource cleanup
client = BrowserNativeClient(
api_key='your-api-key',
base_url='https://bnca-api.fly.dev', # Optional
timeout=30, # Request timeout in seconds
retries=2, # Number of retries
verbose=False # Enable debug logging
)Extract structured content from any webpage.
result = client.scrape(
'https://example.com',
include_screenshot=True # Optional: include screenshot
)
# Response includes:
# - data: Extracted content (title, text, meta, etc.)
# - method: Extraction method used
# - performance: Timing metricsAsk questions about any webpage using AI.
result = client.analyze(
'https://news.site.com',
'What are the top 3 stories?',
include_screenshot=False
)
# Response includes:
# - answer: AI-generated response
# - metadata: Performance and method infoCapture full-page screenshots.
result = client.screenshot('https://example.com')
base64_image = result['data']['screenshot']Optimized screenshot capture for speed.
result = client.quickshot('https://example.com')Get your API usage statistics.
usage = client.get_usage(days=7)
print(usage['data'])Check API status and your account.
health = client.health_check()
print(health['data']['status'])Automatically clean up resources:
with BrowserNativeClient('your-api-key') as client:
result = client.scrape('https://example.com')
# Resources are automatically cleaned upurls = ['https://site1.com', 'https://site2.com', 'https://site3.com']
with BrowserNativeClient('your-api-key') as client:
for url in urls:
try:
result = client.scrape(url)
print(f"β {url}: {result['data']['title']}")
except Exception as e:
print(f"β {url}: {e}")from browsernative import BrowserNativeClient
client = BrowserNativeClient('your-api-key', verbose=True)
try:
result = client.scrape('https://invalid-url')
except ValueError as e:
print(f"Invalid input: {e}")
except Exception as e:
print(f"API error: {e}")# Analyze multiple aspects of a page
questions = [
"What is the main topic?",
"Is there pricing information?",
"What features are highlighted?"
]
with BrowserNativeClient('your-api-key') as client:
for question in questions:
result = client.analyze('https://product.com', question)
print(f"Q: {question}")
print(f"A: {result['data']['answer']}\n")- Visit https://bnca.monostate.ai
- Sign up for an account
- Generate your API key from the dashboard
- Python 3.8+
requestslibrary (automatically installed)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.