Skip to main content

Chrome DevTools Protocol Toolkit in Python

Project description

CDPKit: A Python Implementation of the CDP(Chrome DevTools Protocol)Toolkit

English | 中文

Overview

CDPKit is a toolkit for the Chrome DevTools Protocol (CDP). The protocol component of this project is built on pydantic, supporting friendly code completion and parameter type checking. It also provides a connection module that enables CDP interactions via the remote-debugging-port.

Key Features

  • Type Safety: Leverages pydantic to automatically implement type checking for command inputs and outputs.
  • Rich Type Hints: Provides type hints for command results, eliminating the need to consult documentation for return values.
  • Dynamic Code Generation: Generates protocol code based on the official CDP JSON schema, ensuring fast updates.
  • Async Performance: Offers an asynchronous CDPSessionManager that abstracts communication logic, allowing direct method calls.

Installation

1. Install by pip

pip install cdpkits

2. Install by uv

curl -LsSf https://astral.sh/uv/install.sh | sh  # macOS and Linux
# on Windows:
# powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  • 2.2. Clone the repository:
git clone https://github.com/yie1d/cdpkit.git  
cd cdpkit
  • 2.3. Create a new virtual environment and activate it:
uv venv
source .venv/bin/activate  # On Unix/macOS
# Or on Windows:
# .venv\Scripts\activate
  • 2.4. Install dependencies:
uv sync

Basic Usage

import asyncio
from cdpkit.connection import CDPSessionManager
from cdpkit.protocol import Target


async def main():
    session_manager = CDPSessionManager(connection_port=9222)
    cdp_session = await session_manager.get_session()

    target_resp = await cdp_session.execute(Target.GetTargets())

    for target_info in target_resp.targetInfos:
        print(target_info.model_dump())



asyncio.run(main())

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

cdpkits-1.2.5.tar.gz (188.8 kB view details)

Uploaded Source

Built Distribution

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

cdpkits-1.2.5-py3-none-any.whl (269.2 kB view details)

Uploaded Python 3

File details

Details for the file cdpkits-1.2.5.tar.gz.

File metadata

  • Download URL: cdpkits-1.2.5.tar.gz
  • Upload date:
  • Size: 188.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for cdpkits-1.2.5.tar.gz
Algorithm Hash digest
SHA256 68cb84fcc868e533727f17eb0f39b3829b1f5f7800e98bb776a07dce80d4a9ee
MD5 ce3e25661217ee03cb748a843144aeb2
BLAKE2b-256 2f60fc6b6ed9d015125ca2a03ee69163ba0c111b94516f70e29434fe233ce348

See more details on using hashes here.

File details

Details for the file cdpkits-1.2.5-py3-none-any.whl.

File metadata

  • Download URL: cdpkits-1.2.5-py3-none-any.whl
  • Upload date:
  • Size: 269.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for cdpkits-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 53e764bc5ec8c0a406b33a8311f0d389fa27ad1468dc68c40aa131bdab84fac4
MD5 8a583ab9ddb29fdd25a1f6076252f54f
BLAKE2b-256 3885f68243c446d839c54e62d52ba206286cc97684b2550d2ed47b82a511de50

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