Skip to content

lessless/light_cdp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightCDP

A minimal Elixir client for the Chrome DevTools Protocol. Connects directly to Lightpanda via WebSocket. No Node.js required.

Quick example

{:ok, session} = LightCDP.start()
{:ok, page} = LightCDP.new_page(session)

:ok = LightCDP.Page.navigate(page, "https://example.com")
{:ok, title} = LightCDP.Page.evaluate(page, "document.title")
# => {:ok, "Example Domain"}

LightCDP.stop(session)

See docs/sample.exs for a full extraction script that searches Hacker News and returns structured results.

Installation

Add light_cdp to your dependencies:

def deps do
  [
    {:light_cdp, github: "lessless/light_cdp"}
  ]
end

Install the Lightpanda binary:

curl -fsSL https://pkg.lightpanda.io/install.sh | bash

This places the binary at ~/.local/bin/lightpanda, which is where LightCDP looks by default.

Documentation

API docs are in the source modules — generate locally with mix docs, or read the @doc attributes directly:

  • LightCDP — start/stop sessions, create pages
  • LightCDP.Page — navigate, evaluate, click, fill, submit, wait_for_selector, wait_for_navigation
  • LightCDP.Connection — low-level WebSocket CDP client
  • LightCDP.Server — Lightpanda process management
  • LightCDP.Protocol — CDP message encoding/decoding

How it works

LightCDP talks CDP over WebSocket directly to Lightpanda's built-in CDP server.

Elixir (LightCDP) --WebSocket--> Lightpanda (CDP server) --HTTP--> target site

Page interactions use native CDP methods where Lightpanda supports them (DOM.querySelector, DOM.getBoxModel, Input.dispatchMouseEvent, Input.insertText, DOM.getOuterHTML), falling back to Runtime.evaluate for operations without a CDP equivalent.

License

MIT

About

Lightweight CDP is a lightweight ChromeRemote-style library that connects to any CDP endpoint

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages