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.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-py3-none-any.whl (393.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chromedeveloperprotocol_client-0.2.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.tar.gz
Algorithm Hash digest
SHA256 8712dcc57e2eca8fe1804c424291aac896860cbf991d87b75b64c8b2b21ac65d
MD5 44376dee5104f4aa3594081fb473d338
BLAKE2b-256 0ca2e1fbb0a0fd681fd4061f10c68c3675614cb8bb1f59357331c17c684d3d80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chromedeveloperprotocol_client-0.2-py3-none-any.whl
  • Upload date:
  • Size: 393.3 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-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec664e7789aafee27f13be312c86769ccab7cfdcec93e7bfe8dbe7333e2fc71
MD5 df93ee87f70e4c92de9c44e27f0dcf7d
BLAKE2b-256 e2eb2fa53a94638f244ebb84897cb8d49839f26035be0068915416dd76ad2719

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