Skip to main content

Python wrapper for Chrome DevTools Protocol

Project description

CDP Client

Python wrapper for Chrome DevTools Protocol.

Installation

pip install chromedeveloperprotocol-client

Usage

This example shows how to connect to a running browser and fetch its version information.

Hello World Example

import asyncio
import httpx
from cdp import Client

async def get_ws_url(port=9222):
    async with httpx.AsyncClient() as http:
        resp = await http.get(f"http://localhost:{port}/json/version")
        return resp.json()['webSocketDebuggerUrl']

async def main():
    # Connect to an existing browser session
    # Browser must be started with --remote-debugging-port=9222
    ws_url = await get_ws_url()
    
    async with Client(ws_url) as client:
        # Fetch browser version information
        version = await client.browser.get_version({})
        print(f"Browser: {version['product']}")
        
        # Create a new page and navigate
        target = await client.target.create_target({"url": "https://www.google.com"})
        print(f"Created target: {target['targetId']}")

if __name__ == "__main__":
    asyncio.run(main())

Running the Examples

Ensure you have a browser (Chrome or Edge) running with remote debugging enabled:

chrome.exe --remote-debugging-port=9222

Updating the CDP Protocols

The library automatically generates its protocol definitions from the upstream ChromeDevTools/devtools-protocol repository during build/installation.

To fetch the latest protocol definitions and update the client code, run:

uv sync --reinstall-package chromedeveloperprotocol-client

This will trigger the build hook which pulls the latest JSON files and regenerates the src/cdp directory.

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

chromedeveloperprotocol_client-0.2.1.tar.gz (250.5 kB view details)

Uploaded Source

Built Distribution

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

chromedeveloperprotocol_client-0.2.1-py3-none-any.whl (389.1 kB view details)

Uploaded Python 3

File details

Details for the file chromedeveloperprotocol_client-0.2.1.tar.gz.

File metadata

  • Download URL: chromedeveloperprotocol_client-0.2.1.tar.gz
  • Upload date:
  • Size: 250.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chromedeveloperprotocol_client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 671131d436cc4d217fec0f6f1762d36cd4baec03eaaeb070f169be4ae915145d
MD5 accf84d11dd202e02ae62baffcc69201
BLAKE2b-256 cd4b8bfd4e0352cf2f5de3f38d35c6a684e5ff0fcb71a2499678f73e3e16556f

See more details on using hashes here.

File details

Details for the file chromedeveloperprotocol_client-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: chromedeveloperprotocol_client-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 389.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chromedeveloperprotocol_client-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b213dc2db97a5ee6aaee47b7ac69899d07ceaa1bec196e2880f8857d4134be3
MD5 363d04237b56a546a1d383c04c68964c
BLAKE2b-256 438866d74b2e223abc3abc0d445949f808e5a143dab06b20d591de9d1cbd6487

See more details on using hashes here.

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