Metadata-Version: 2.4
Name: cf-browser
Version: 2.0.0
Summary: Python SDK for Cloudflare Browser Rendering — read any web page from Python (Worker + Direct mode)
Project-URL: Homepage, https://github.com/claude-world/cf-browser
Project-URL: Documentation, https://github.com/claude-world/cf-browser#readme
Project-URL: Repository, https://github.com/claude-world/cf-browser
Project-URL: Issues, https://github.com/claude-world/cf-browser/issues
Project-URL: Changelog, https://github.com/claude-world/cf-browser/blob/main/CHANGELOG.md
Author-email: Claude World <hello@claude-world.com>
License-Expression: MIT
License-File: LICENSE
Keywords: browser-automation,browser-rendering,claude-code,cloudflare,headless-chrome,mcp,web-scraping
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: respx; extra == 'dev'
Description-Content-Type: text/markdown

# cf-browser

Python SDK for [CF Browser](https://github.com/claude-world/cf-browser) — read any JavaScript-rendered web page from Python.

## Installation

```bash
pip install cf-browser
```

## Usage

```python
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](https://github.com/claude-world/cf-browser)

## License

[MIT](https://github.com/claude-world/cf-browser/blob/main/LICENSE)
