Official Python SDK for Browser7 - Geo-targeted web scraping with automatic CAPTCHA solving and wait actions
Project description
Browser7 Python SDK
Official Python client for the Browser7 web scraping and rendering API.
Browser7 provides geo-targeted web scraping with automatic proxy management, CAPTCHA solving, and powerful wait actions for dynamic content.
Features
- 🌍 Geo-Targeting - Render pages from specific countries and cities using residential proxies
- 🤖 CAPTCHA Solving - Automatic detection and solving of reCAPTCHA and Cloudflare Turnstile
- 📸 Screenshots - Capture viewport or full-page screenshots in PNG or JPEG
- 🌐 In-Browser Fetch - Fetch additional URLs through the rendered page's browser context
- ⏱️ Wait Actions - Click elements, wait for selectors, text content, or delays
- 🚀 Performance - Block images, track bandwidth, view timing breakdowns
- 🔄 Automatic Polling - Built-in polling with progress callbacks
- 🐍 Async Support - Both synchronous and async clients included
Installation
pip install browser7
Requirements: Python 3.10+
Quick Start
from browser7 import Browser7
client = Browser7(api_key='your-api-key')
# Simple render
result = client.render('https://example.com')
print(result.html)
Authentication
Get your API key from the Browser7 Dashboard.
client = Browser7(api_key='b7_your_api_key_here')
Usage Examples
Basic Rendering
result = client.render('https://example.com', country_code='US')
print(result.html) # Rendered HTML
print(result.selected_city) # City used for rendering
With Wait Actions
from browser7 import wait_for_click, wait_for_selector, wait_for_delay
result = client.render(
'https://example.com',
country_code='GB',
city='london',
wait_for=[
wait_for_click('.cookie-accept'), # Click element
wait_for_selector('.main-content'), # Wait for element
wait_for_delay(2000) # Wait 2 seconds
]
)
With CAPTCHA Solving
result = client.render(
'https://protected-site.com',
country_code='US',
captcha='auto' # Auto-detect and solve CAPTCHAs
)
print(result.captcha) # CAPTCHA detection info
With Screenshots
result = client.render(
'https://example.com',
country_code='US',
include_screenshot=True, # Enable screenshot
screenshot_format='jpeg', # 'jpeg' or 'png'
screenshot_quality=80, # 1-100 (JPEG only)
screenshot_full_page=False # False = viewport only, True = full page
)
# Save screenshot to file
import base64
with open('screenshot.jpg', 'wb') as f:
f.write(base64.b64decode(result.screenshot))
Fetch Additional URLs
result = client.render(
'https://example.com',
fetch_urls=[
'https://example.com/api/data',
'https://example.com/api/user'
]
)
print(result.fetch_responses) # List of fetch responses
Check Account Balance
balance = client.get_account_balance()
print(f"Total: {balance.total_balance_formatted}")
print(f"Renders remaining: {balance.total_balance_cents}")
print(f"\nBreakdown:")
print(f" Paid: {balance.breakdown['paid']['formatted']} ({balance.breakdown['paid']['cents']} renders)")
print(f" Free: {balance.breakdown['free']['formatted']} ({balance.breakdown['free']['cents']} renders)")
print(f" Bonus: {balance.breakdown['bonus']['formatted']} ({balance.breakdown['bonus']['cents']} renders)")
API Reference
Browser7(api_key, base_url=None)
Create a new Browser7 client.
Parameters:
api_key(str, required): Your Browser7 API keybase_url(str, optional): Full API base URL. Defaults to production API.
Example:
# Production (default)
client = Browser7(api_key='your-api-key')
# Canadian endpoint
client = Browser7(
api_key='your-api-key',
base_url='https://ca-api.browser7.com/v1'
)
client.render(url, **options)
Render a URL and poll for the result.
Parameters:
url(str): The URL to rendercountry_code(str, optional): Country code (e.g., 'US', 'GB', 'DE')city(str, optional): City name (e.g., 'new.york', 'london')wait_for(list, optional): List of wait actions (max 10)captcha(str, optional): CAPTCHA mode: 'disabled', 'auto', 'recaptcha_v2', 'recaptcha_v3', 'turnstile'block_images(bool, optional): Block images for faster rendering (default: True)fetch_urls(list, optional): Additional URLs to fetch (max 10)
Returns: RenderResult object
client.get_account_balance()
Get the current account balance.
Returns: AccountBalance object
Example:
balance = client.get_account_balance()
print(f"Total: {balance.total_balance_formatted}")
print(f"Renders remaining: {balance.total_balance_cents}")
AccountBalance attributes:
total_balance_cents(int): Total balance in cents (also equals renders remaining, since 1 cent = 1 render)total_balance_formatted(str): Total balance formatted as USD currency (e.g., "$13.00")breakdown(dict): Balance breakdown by typebreakdown['paid']- Paid balance withcentsandformattedkeysbreakdown['free']- Free balance withcentsandformattedkeysbreakdown['bonus']- Bonus balance withcentsandformattedkeys
Helper Functions
wait_for_delay(duration)
Create a delay wait action.
wait_for_delay(3000) # Wait 3 seconds
wait_for_selector(selector, state='visible', timeout=30000)
Create a selector wait action.
wait_for_selector('.main-content', state='visible', timeout=10000)
wait_for_text(text, selector=None, timeout=30000)
Create a text wait action.
wait_for_text('In Stock', selector='.availability', timeout=10000)
wait_for_click(selector, timeout=30000)
Create a click wait action.
wait_for_click('.cookie-accept', timeout=5000)
Supported Countries
AT, BE, CA, CH, CZ, DE, FR, GB, HR, HU, IT, NL, PL, SK, US
See Browser7 Documentation for available cities per country.
CAPTCHA Support
Browser7 supports automatic CAPTCHA detection and solving for:
- reCAPTCHA v2 - Google's image-based CAPTCHA
- reCAPTCHA v3 - Google's score-based CAPTCHA
- Cloudflare Turnstile - Cloudflare's CAPTCHA alternative
Modes:
'disabled'(default) - Skip CAPTCHA detection (fastest)'auto'- Auto-detect and solve any CAPTCHA type'recaptcha_v2','recaptcha_v3','turnstile'- Solve specific type
Contributing
Issues and pull requests are welcome! Please visit our GitHub repository.
License
MIT
Support
- 📧 Email: support@browser7.com
- 📚 Documentation: https://docs.browser7.com
- 🐛 Issues: https://github.com/browser7data/browser7-python/issues
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browser7-1.0.0.tar.gz.
File metadata
- Download URL: browser7-1.0.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d32b706f4f533a308d6541607af86a1f0e2e4cc8fd6753d2e132e441e0661d
|
|
| MD5 |
0ee1663e27191483fe88eacb006692c9
|
|
| BLAKE2b-256 |
00c2efbaaf15cf98cec96e25a7ac88bef87223533e205042d4150bcb88d670d8
|
File details
Details for the file browser7-1.0.0-py3-none-any.whl.
File metadata
- Download URL: browser7-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd245da34a7ab5bb385222f25a8e82fb305543eff5d036a0944618eb6cc4f7e3
|
|
| MD5 |
9346487a2316a69991401f114077bdc8
|
|
| BLAKE2b-256 |
769e1a75192ff3e7247ffdd004bfb38061a097e956301c0a08069f7c9612c6f4
|