{"library":"mycdp","title":"MyCDP: Autogenerated Chrome DevTools Protocol Client","description":"MyCDP is an autogenerated Python client for the Chrome DevTools Protocol (CDP), providing a direct, low-level interface to control Chrome and Chromium-based browsers. It wraps the latest CDP specification, making it highly synchronized with Chrome's internal API. Current version is 1.3.7, with updates released frequently to reflect changes in CDP.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install mycdp"],"cli":null},"imports":["from mycdp import cdp"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport time\nimport os\nfrom mycdp import cdp\n\n# --- This quickstart requires a Chrome/Chromium browser executable in your PATH ---\n# Start Chrome in headless mode with remote debugging enabled on port 9222\n# Adjust 'google-chrome' to 'chromium', 'chrome', or the full path to your browser\nchrome_executable = os.environ.get('CHROME_EXECUTABLE', 'google-chrome')\nremote_debugging_port = os.environ.get('REMOTE_DEBUGGING_PORT', '9222')\n\nchrome_process = None\nws_url = f\"ws://localhost:{remote_debugging_port}\"\nsession = None\n\ntry:\n    print(f\"Launching {chrome_executable} with remote debugging on port {remote_debugging_port}...\")\n    # Note: stderr/stdout are redirected to PIPE to avoid polluting the console\n    chrome_process = subprocess.Popen(\n        [chrome_executable, '--headless=new', f'--remote-debugging-port={remote_debugging_port}'],\n        stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True\n    )\n    time.sleep(3) # Give Chrome a moment to start and open the debugging port\n\n    # Connect to the running Chrome instance\n    print(f\"Connecting to Chrome at {ws_url}...\")\n    session = cdp.browser.connect(ws_url)\n    print(\"Successfully connected to Chrome.\")\n\n    # Enable the Page domain to receive events and navigate\n    cdp.page.enable(session)\n\n    # Navigate to a URL\n    target_url = \"https://www.example.com\"\n    print(f\"Navigating to {target_url}...\")\n    cdp.page.navigate(session, url=target_url)\n    # Wait for the page to finish loading (load event)\n    cdp.page.wait_for_load_event(session)\n    print(f\"Successfully navigated to {target_url}\")\n\n    # Execute a JavaScript expression to get the page title\n    title_response = cdp.runtime.evaluate(session, expression=\"document.title\")\n    if title_response and title_response.result:\n        print(f\"Page title: {title_response.result.value}\")\n\n    # Example: Get all cookies\n    cookies_response = cdp.storage.get_cookies(session)\n    if cookies_response and cookies_response.cookies:\n        print(f\"Found {len(cookies_response.cookies)} cookies.\")\n        # for cookie in cookies_response.cookies:\n        #    print(f\" - {cookie.name}: {cookie.value}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    # Print stderr if Chrome process is available and has output\n    if chrome_process:\n        try:\n            _, stderr_output = chrome_process.communicate(timeout=1)\n            if stderr_output:\n                print(\"Chrome stderr:\", stderr_output)\n        except subprocess.TimeoutExpired:\n            chrome_process.kill()\n            print(\"Chrome stderr: Process timed out during communicate, killed.\")\n\nfinally:\n    # Always close the CDP session and terminate the Chrome process\n    if session:\n        print(\"Closing CDP session...\")\n        cdp.browser.close(session)\n    if chrome_process and chrome_process.poll() is None:\n        print(\"Terminating Chrome process...\")\n        chrome_process.terminate()\n        try:\n            chrome_process.wait(timeout=5)\n        except subprocess.TimeoutExpired:\n            chrome_process.kill()\n            print(\"Chrome process did not terminate gracefully, killed.\")\n    print(\"Quickstart finished.\")","lang":"python","description":"This example launches a headless Chrome instance, connects to it via MyCDP, navigates to 'example.com', retrieves its title, and lists its cookies. It demonstrates connecting to a browser, enabling a CDP domain, and executing basic page and runtime commands. Ensure you have a Chrome/Chromium executable in your system's PATH (e.g., 'google-chrome', 'chromium').","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"1.3.7","pypi_latest":"1.3.7","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"22.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"23M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"14.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"15M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"14.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"15M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mycdp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"20M"}]}}