GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - douglasdcm/python-chrome-devtools-protocol: Python type wrappers for Chrome DevTools Protocol (CDP)

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

162 Commits
162 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
cdp
cdp
 
 
docs
docs
 
 
examples
examples
 
 
generator
generator
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.readthedocs.yml
.readthedocs.yml
 
 
.travis.yml
.travis.yml
 
 
IMPLEMENTATION.md
IMPLEMENTATION.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
SECURITY_UPDATES.md
SECURITY_UPDATES.md
 
 
mypy.ini
mypy.ini
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

PyCDP

PyPI Python Versions MIT License Build Status Read the Docs

Python Chrome DevTools Protocol (shortened to PyCDP) is a library that provides Python wrappers for the types, commands, and events specified in the Chrome DevTools Protocol.

The Chrome DevTools Protocol provides for remote control of a web browser by sending JSON messages over a WebSocket. That JSON format is described by a machine-readable specification. This specification is used to automatically generate the classes and methods found in this library.

You could write a CDP client by connecting a WebSocket and then sending JSON objects, but this would be tedious and error-prone: the Python interpreter would not catch any typos in your JSON objects, and you wouldn't get autocomplete for any parts of the JSON data structure. By providing a set of native Python wrappers, this project makes it easier and faster to write CDP client code.

Two Usage Modes

Sans-I/O Mode (original): The core library provides type wrappers without performing any I/O. This maximizes flexibility and allows integration with any async framework. This is ideal for users who want to integrate CDP with their own I/O stack or use libraries like trio-chrome-devtools-protocol.

I/O Mode (new): The library now includes cdp.connection module that provides WebSocket I/O, JSON-RPC message framing, and command multiplexing out of the box. This makes it easy to get started with CDP without writing any I/O code yourself.

Installation

Basic installation (Sans-I/O mode only):

pip install chrome-devtools-protocol

With I/O support:

pip install chrome-devtools-protocol[io]

Quick Start with I/O Mode

import asyncio
from cdp.connection import CDPConnection
from cdp import page

async def main():
    # Connect to a Chrome DevTools Protocol endpoint
    async with CDPConnection("ws://localhost:9222/devtools/page/YOUR_PAGE_ID") as conn:
        # Navigate to a URL
        frame_id, loader_id, error = await conn.execute(
            page.navigate(url="https://example.com")
        )
        print(f"Navigated to example.com, frame_id: {frame_id}")

asyncio.run(main())

Key Features of I/O Mode

  • WebSocket Management: Automatic connection lifecycle management with async context managers
  • JSON-RPC Framing: Automatic message ID assignment and request/response matching
  • Command Multiplexing: Execute multiple commands concurrently with proper tracking
  • Event Handling: Async iterator for receiving browser events
  • Error Handling: Comprehensive error handling with typed exceptions

See the examples directory for more usage patterns.

Sans-I/O Mode (Original)

For users who prefer to manage their own I/O:

Sans-I/O Mode (Original)

For users who prefer to manage their own I/O:

from cdp import page

frame_id = page.FrameId('my id')
assert repr(frame_id) == "FrameId('my id')"

For more information, see the complete documentation.

define hyperion gray

About

Python type wrappers for Chrome DevTools Protocol (CDP)

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.