Skip to main content

cidipi

Low-level client for interacting with Chrome Devtools Protocol (CDP) for Python.

Installation

pip install cidipi

Usage

import asyncio
import logging
from typing import cast

from cidipi.client import Browser
from cidipi.models import EventResponse, Payload, Tab
from cidipi.protocols import commands, events

logging.basicConfig(
    level=logging.DEBUG, format="[%(levelname)s] [%(name)s] %(message)s"
)
logging.getLogger("websockets.client").disabled = True


async def navigate(tab: Tab, *, url: str, wait_until: str):
    async def wait_for(data: Payload, result: asyncio.Future):
        if data.kind == "result":
            return

        cdp_event_klass = events.Page.lifecycleEvent
        cdp_event_name = cdp_event_klass.get_method_name()
        resp_data = cast(EventResponse, data.data)
        if resp_data["method"] == cdp_event_name:
            obj = cdp_event_klass(**resp_data["params"])
            if obj.name == wait_until:
                result.set_result(None)

    return await tab.execute(
        commands.Page.navigate(url=url), callback=wait_for, timeout=30
    )


async def main():
    async with Browser(headless=False, remote_port=0) as browser:

        async def run(url: str):
            async with browser.new_tab() as tab:
                await tab.execute(commands.Page.enable())
                await tab.execute(commands.Page.setLifecycleEventsEnabled(enabled=True))
                await navigate(tab, url=url, wait_until="load")

        await run("https://www.google.com")


if __name__ == "__main__":
    asyncio.run(main())

See the examples/ directory to get started.

Metadata

Release files for cidipi 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cidipi 0.2.0
File Size Uploaded Provenance Actions
cidipi-0.2.0.tar.gz 132.6 kB Without provenance Details for cidipi-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cidipi 0.2.0
File Interpreter ABI Platform Actions
cidipi-0.2.0-py3-none-any.whl Python 3 none any Details for cidipi-0.2.0-py3-none-any.whl

Total release size: 268.2 kB

Release files / cidipi-0.2.0.tar.gz

Download URL cidipi-0.2.0.tar.gz
Size 132.6 kB
Tags Source
SHA-256 checksum
How to use checksums
98ed956783517531b3c6ca768b1d4d245e2834e44c00447a526f9bcdc3a7d41e
BLAKE2b-256 checksum
How to use checksums
173641dd2a15c65e464c63bddb34df89f01f7ea0d10de9da5010f66441ae11c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / cidipi-0.2.0-py3-none-any.whl

Download URL cidipi-0.2.0-py3-none-any.whl
Size 135.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
723d3c77c6626412f17b7a1921d5466e5f937e42d65ebc74f978316ee11f1a4e
BLAKE2b-256 checksum
How to use checksums
e1ffdda08aedfcb5eab11bfe3f2cbbae78e200bdb1e9f0f46a30a70ff4e3d9a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Security for cidipi 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page