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
pydanticto 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
- 2.1. Install uv(if not currently installed)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdpkits-1.2.7.tar.gz.
File metadata
- Download URL: cdpkits-1.2.7.tar.gz
- Upload date:
- Size: 190.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
326c036eb1eb43ace8dbde50b7b2a4c5be5c33cd6a7111b5246fc1fbe7413688
|
|
| MD5 |
87916bfac7d9b5b77a3038f5efe75ab1
|
|
| BLAKE2b-256 |
23b584d4ed3afc52c5efa413a158dddca2a615a32388fa2e2f33af7e43971ed4
|
File details
Details for the file cdpkits-1.2.7-py3-none-any.whl.
File metadata
- Download URL: cdpkits-1.2.7-py3-none-any.whl
- Upload date:
- Size: 272.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5db377fee7bc2584c53a2efabf5c8cdfbed63784c72917dafeab0b37bf1768e9
|
|
| MD5 |
c0385d47aa485780cbfebf3ce2254546
|
|
| BLAKE2b-256 |
fce1c48bf2085f82143d26a0d461e6f8f716216cb40877e582f18e3a14a7ef3d
|