{"id":28187430,"url":"https://github.com/yie1d/cdpkit","last_synced_at":"2026-03-02T13:03:40.372Z","repository":{"id":290156183,"uuid":"973552647","full_name":"yie1d/cdpkit","owner":"yie1d","description":"Chrome DevTools Protocol Toolkit in Python","archived":false,"fork":false,"pushed_at":"2025-12-12T07:41:15.000Z","size":1037,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T18:06:33.488Z","etag":null,"topics":["aiohttp","chrome-debugging-protocol","chrome-devtools-protocol","chromium","pydantic-v2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yie1d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-27T08:30:40.000Z","updated_at":"2025-12-12T07:41:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9ac2ca1-acde-4a94-984a-2ae810d2610c","html_url":"https://github.com/yie1d/cdpkit","commit_stats":null,"previous_names":["yie1d/cdpkit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yie1d/cdpkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yie1d%2Fcdpkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yie1d%2Fcdpkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yie1d%2Fcdpkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yie1d%2Fcdpkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yie1d","download_url":"https://codeload.github.com/yie1d/cdpkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yie1d%2Fcdpkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30003484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T12:19:43.414Z","status":"ssl_error","status_checked_at":"2026-03-02T12:19:02.215Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","chrome-debugging-protocol","chrome-devtools-protocol","chromium","pydantic-v2"],"created_at":"2025-05-16T08:09:48.242Z","updated_at":"2026-03-02T13:03:40.356Z","avatar_url":"https://github.com/yie1d.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ⚠️ DEPRECATED - This project is no longer maintained\n\n**We recommend using [cdp-use](https://github.com/browser-use/cdp-use) instead.**\n\ncdp-use is a more modern, type-safe Python CDP client with:\n- Zero runtime overhead (TypedDict instead of Pydantic)\n- Better API design and IDE support\n- Lighter dependencies\n- Active maintenance\n\n---\n\n## CDPKit: A Python Implementation of the CDP([Chrome DevTools Protocol](https://github.com/ChromeDevTools/devtools-protocol/tree/master/json))Toolkit\n\nEnglish  | [中文](doc/README_cn.md) \n\n## Overview\n\nCDPKit is a toolkit for the Chrome DevTools Protocol (CDP). The protocol component of this project is built on [pydantic](https://github.com/pydantic/pydantic), supporting friendly code completion and parameter type checking. It also provides a connection module that enables CDP interactions via the `remote-debugging-port`.\n\n## Key Features  \n- **Type Safety**: Leverages `pydantic` to automatically implement type checking for command inputs and outputs.\n- **Rich Type Hints**: Provides type hints for command results, eliminating the need to consult documentation for return values.\n- **Dynamic Code Generation**: Generates protocol code based on the official [CDP JSON](https://github.com/ChromeDevTools/devtools-protocol/tree/master/json) schema, ensuring fast updates.\n- **Async Performance**: Offers an asynchronous CDPSessionManager that abstracts communication logic, allowing direct method calls.\n\n## Installation\n#### 1. Install by pip\n```shell\npip install cdpkits\n```\n\n#### 2. Install by [uv](https://github.com/astral-sh/uv)\n- 2.1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)(if not currently installed)\n```shell\ncurl -LsSf https://astral.sh/uv/install.sh | sh  # macOS and Linux\n# on Windows:\n# powershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n```\n- 2.2. Clone the repository:\n```shell\ngit clone https://github.com/yie1d/cdpkit.git  \ncd cdpkit\n```\n- 2.3. Create a new virtual environment and activate it:\n```shell\nuv venv\nsource .venv/bin/activate  # On Unix/macOS\n# Or on Windows:\n# .venv\\Scripts\\activate\n```\n- 2.4. Install dependencies:\n```shell\nuv sync\n```\n\n## Basic Usage\n### Quick Start\n```python\nimport asyncio\nfrom cdpkit.connection import CDPSessionManager\nfrom cdpkit.protocol import Target\n\n\nasync def main():\n    # Connect to the currently running browser (debug port 9222)\n    session_manager = CDPSessionManager(ws_endpoint='localhost:9222')\n    cdp_session = await session_manager.get_session()\n    \n    # Get information on all currently open targets.\n    target_resp = await cdp_session.execute(Target.GetTargets())\n\n    for target_info in target_resp.targetInfos:\n        print(target_info.model_dump())\n\n\n\nasyncio.run(main())\n\n```\n### Use `CDPSessionExecutor`\n\n```python\nimport asyncio\nfrom cdpkit.connection import CDPSessionManager, CDPSessionExecutor\nfrom cdpkit.protocol import Target, Page\n\n\nasync def on_dialog_open(event_data: Page.JavascriptDialogOpening):\n    \"\"\"\n    Callback function for the alert dialog\n\n    Args:\n        event_data (Page.JavascriptDialogOpening): \n            If the event_data parameter is provided, \n            it must be used as the parameter for receiving the event and must match the actual event type.\n\n    Returns:\n\n    \"\"\"\n    print(event_data.message)\n\nasync def main():\n    session_manager = CDPSessionManager(ws_endpoint='localhost:9225')\n    browser_session = await session_manager.get_session()\n\n\n    # execute command\n    target_resp = await browser_session.execute(Target.GetTargets(filter_=[{\n        'type': 'page',\n        'exclude': False\n    }]))\n\n    target_id = None\n    for target_info in target_resp.targetInfos:\n        if not target_info.url.startswith('devtools://') and not target_info.url.startswith('chrome-extension://'):\n            target_id = target_info.targetId\n            break\n\n    if not target_id:\n        raise Exception('No target found')\n\n    # Retrieve the specified target session\n    cdp_session = await session_manager.get_session(target_id=target_id)\n    session_executor = CDPSessionExecutor(session=cdp_session, session_manager=session_manager)\n\n    # execute by CDPSessionExecutor\n    # Enable page events\n    await session_executor.execute_method(Page.Enable())\n\n    # Listen for events\n    await session_executor.on(\n        event=Page.JavascriptDialogOpening,\n        callback=on_dialog_open\n    )\n\n    # You can manually run alert('test Page.JavascriptDialogOpening event') in the browser's console to see the listener in action.\n    await asyncio.sleep(500)\n\n\n\nasyncio.run(main())\n```\n\n### More usage\nYou can refer to [webauto](https://github.com/yie1d/webauto.git) — a browser-automation tool based on `CDPKit` (work in progress).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyie1d%2Fcdpkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyie1d%2Fcdpkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyie1d%2Fcdpkit/lists"}