Python SDK for Cloudflare Browser Rendering — read any web page from Python (Worker + Direct mode)
Project description
cf-browser
Python SDK for CF Browser — read any JavaScript-rendered web page from Python.
Installation
pip install cf-browser
Usage
from cf_browser import CFBrowser
async with CFBrowser(
base_url="https://cf-browser.YOUR-SUBDOMAIN.workers.dev",
api_key="your-api-key",
) as browser:
# Read a page as Markdown
md = await browser.markdown("https://react.dev")
# Take a screenshot
png = await browser.screenshot("https://example.com", width=1280)
# AI-powered data extraction
data = await browser.json_extract(
"https://news.ycombinator.com",
prompt="Extract top 5 stories with title and score",
)
# Accessibility tree (low token cost)
tree = await browser.a11y("https://example.com")
# Authenticated scraping
md = await browser.markdown(
"https://app.example.com/dashboard",
cookies=[{"name": "session", "value": "abc", "domain": ".example.com"}],
)
Methods
| Method | Returns | Description |
|---|---|---|
content(url) |
str |
Rendered HTML |
markdown(url) |
str |
Clean Markdown |
screenshot(url) |
bytes |
PNG image |
pdf(url) |
bytes |
PDF document |
snapshot(url) |
dict |
HTML + metadata |
scrape(url, selectors) |
dict |
Elements by CSS selector |
json_extract(url, prompt) |
dict |
AI-extracted data |
links(url) |
list[dict] |
All hyperlinks |
a11y(url) |
dict |
Accessibility tree |
crawl(url) |
str |
Async crawl job ID |
crawl_status(job_id) |
dict |
Job status |
crawl_wait(job_id) |
dict |
Wait for completion |
All methods accept no_cache=True, cookies, and headers kwargs.
Requirements
- Python 3.10+
- A deployed CF Browser Worker
License
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 cf_browser-2.0.0.tar.gz.
File metadata
- Download URL: cf_browser-2.0.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21a9f1db8eeb96727d89bed8d4beff53e42742209db5c9174a204b17645a63d4
|
|
| MD5 |
a293a7a4197d6b65612089ccf75051d1
|
|
| BLAKE2b-256 |
a2133facf0bb8d24500e394c52764724bc2ad96da24996ed8e141320a9ec48cb
|
Provenance
The following attestation bundles were made for cf_browser-2.0.0.tar.gz:
Publisher:
publish.yml on claude-world/cf-browser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cf_browser-2.0.0.tar.gz -
Subject digest:
21a9f1db8eeb96727d89bed8d4beff53e42742209db5c9174a204b17645a63d4 - Sigstore transparency entry: 1112739899
- Sigstore integration time:
-
Permalink:
claude-world/cf-browser@37d8a191089e16d63f74b8370093d48dc2316fbe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/claude-world
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@37d8a191089e16d63f74b8370093d48dc2316fbe -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cf_browser-2.0.0-py3-none-any.whl.
File metadata
- Download URL: cf_browser-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211899d8342763f655caf4f5610554cad24d53f4003f90ec11df495d10a17f12
|
|
| MD5 |
79117ea9cc83160fba90fadc00933106
|
|
| BLAKE2b-256 |
9d8d8b480dc2d30702c36d729b4209aa5eed630c3cddfa1ace046c8d9b4943e6
|
Provenance
The following attestation bundles were made for cf_browser-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on claude-world/cf-browser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cf_browser-2.0.0-py3-none-any.whl -
Subject digest:
211899d8342763f655caf4f5610554cad24d53f4003f90ec11df495d10a17f12 - Sigstore transparency entry: 1112740016
- Sigstore integration time:
-
Permalink:
claude-world/cf-browser@37d8a191089e16d63f74b8370093d48dc2316fbe -
Branch / Tag:
refs/heads/main - Owner: https://github.com/claude-world
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@37d8a191089e16d63f74b8370093d48dc2316fbe -
Trigger Event:
workflow_dispatch
-
Statement type: