https://github.com/symonk/python-cdp
:snake: Pythonic marshalling for the devtools protocol
https://github.com/symonk/python-cdp
chrome devtools-protocol python
Last synced: about 1 month ago
JSON representation
:snake: Pythonic marshalling for the devtools protocol
- Host: GitHub
- URL: https://github.com/symonk/python-cdp
- Owner: symonk
- License: apache-2.0
- Created: 2023-03-11T22:06:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-24T19:58:12.000Z (almost 2 years ago)
- Last Synced: 2024-04-29T10:23:07.785Z (about 1 year ago)
- Topics: chrome, devtools-protocol, python
- Language: Python
- Homepage: https://symonk.github.io/python-cdp/
- Size: 1.93 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://pypi.org/project/python-cdp/)
[](https://pypi.org/project/python-cdp/)
[](https://codecov.io/gh/symonk/python-cdp)
[](https://symonk.github.io/python-cdp/)# python-cdp (**ALPHA**)
-----
`python-cdp` is a python library that can be used to attach to a remotely running chrome instance for debugging. In order to
connect to the browser it should be launched with `--remote-debugging-port=X`. `python-cdp` exposes a simple client for `asyncio`
and various wrappers for the devtools protocol. This is all event driven and bidirectional via websockets.The protocol itself at the tip of tree is moving fast, this library aims to support all domains that are not currently deprecated.
-----
#### Low Level Details
Chrome devtools protocol is built on the concept of `Domains`. These domains typically expose an API
in the form of:* Commands
* Types
* EventsEach `Domain` advertised by the CDP will have its own module file written in `python_cdp/cdp/{domain}.py` and have fully
type hinted classes for (de)serialisation.-----
### Goals for Future`python-cdp` aims to implement a typed API for the protocol (and maintain) that fully going forward. Eventually
it hopes to expose a websocket connection/API for actually interacting with the protocol but that is a way
off yet.- Full marshalling capabilities for all non deprecated domains.
- An `asyncio` client for interacting and connecting to chrome in debug mode.
- Useful utilities for making interactions that little bit easier.
- 100% type hinted code base
- Completely auto generated client to make changes and releases as pain free as possible.
- Auto detection of upstream protocol rollups and auto releases triggered.-----
## Contributing
This project takes the devtools protocol json files and based on those generates python source code. It is not currently building
AST trees to unparse but it may do so in future, for now it is generating relatively complex source code (largely in the form of
python dataclasses). In order to generate the files again do the following:```shell
poetry shell
poetry install
python -m python_cdp.generate
tox -e linting # format the generated source code (will unstage)
# inspect the `python_cdp/cdp/*` directory.
```The CDP protocol repository is a submodule within this repository and will be automatically updated when google releases changes on
the upstream repository.The power of keeping the repository auto generated is that it requires minimmal maintenance work when the `tip-of-the-tree` for the
protocol is updated which is pretty much every day, the target is forever moving.-----
## Useful utilities
The below examples use the power `jq` tool to generate output that can be useful for debugging or checking things that should be
generated etc.### Generating all the possible properties that an `Event` class may need: