Skip to main content

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

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

cf_browser-2.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

cf_browser-2.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

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

Hashes for cf_browser-2.0.0.tar.gz
Algorithm Hash digest
SHA256 21a9f1db8eeb96727d89bed8d4beff53e42742209db5c9174a204b17645a63d4
MD5 a293a7a4197d6b65612089ccf75051d1
BLAKE2b-256 a2133facf0bb8d24500e394c52764724bc2ad96da24996ed8e141320a9ec48cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cf_browser-2.0.0.tar.gz:

Publisher: publish.yml on claude-world/cf-browser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for cf_browser-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 211899d8342763f655caf4f5610554cad24d53f4003f90ec11df495d10a17f12
MD5 79117ea9cc83160fba90fadc00933106
BLAKE2b-256 9d8d8b480dc2d30702c36d729b4209aa5eed630c3cddfa1ace046c8d9b4943e6

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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