Metadata-Version: 2.4
Name: chrome-remote-interface
Version: 1.0.0
Summary: A low-level asynchronous Python client for the Chrome DevTools Protocol
License-Expression: MIT
Keywords: chrome,chromium,cdp,devtools,protocol
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typing_extensions>=4.12
Requires-Dist: websockets<17,>=12
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: pyright>=1.1.390; extra == "dev"
Requires-Dist: ruff>=0.9; extra == "dev"
Dynamic: license-file

# chrome-remote-interface

A low-level asynchronous Python client for the Chrome DevTools Protocol (CDP),
inspired by the Node.js
[`chrome-remote-interface`](https://github.com/cyrus-and/chrome-remote-interface)
package.

This package deliberately exposes CDP directly. It does not provide browser
automation abstractions such as browsers, pages, locators, selectors, or input
helpers.

## Installation

```console
pip install chrome-remote-interface
```

Start Chrome with remote debugging enabled:

```console
chrome --remote-debugging-port=9222
```

## Usage

```python
import asyncio

from cdp import connect


async def main() -> None:
    client = await connect()
    try:
        await client.Page.enable()
        await client.Runtime.enable()

        loaded = client.Page.loadEventFired()
        await client.Page.navigate(url="https://example.com")
        await loaded

        result = await client.Runtime.evaluate(
            expression="document.title",
            returnByValue=True,
        )
        print(result["result"]["value"])
    finally:
        await client.close()


asyncio.run(main())
```

Commands can also be sent without domain shorthand:

```python
result = await client.send(
    "Runtime.evaluate",
    {"expression": "location.href", "returnByValue": True},
)
```

Listen for events with a callback:

```python
unsubscribe = client.Network.requestWillBeSent(
    lambda event: print(event["request"]["url"])
)
await client.Network.enable()

# Later:
unsubscribe()
```

Connect to a specific target:

```python
from cdp import List, connect

targets = await List()
client = await connect(targets[0]["id"])
```

## DevTools HTTP helpers

The package exports the same family of discovery helpers as the Node.js
library:

- `Protocol(options=None)`
- `List(options=None)`
- `New(options=None)`
- `Activate(options)`
- `Close(options)`
- `Version(options=None)`

Connection and helper options include `host`, `port`, `secure`, and `timeout`.
The defaults are `localhost:9222`.

## Development

```console
python -m pip install -e ".[dev]"
python -m unittest discover -s tests
ruff check .
pyright
python -m build
```
