#cdp #chrome-dev-protocol

cdp-rs

Chrome Dev Protocol client written in Rust

6 releases

0.3.3 Jan 8, 2023
0.3.2 Nov 8, 2022
0.2.0 Nov 8, 2022
0.1.0 Nov 7, 2022

#3 in #cdp

Download history 48/week @ 2023-10-22 20/week @ 2023-10-29 5/week @ 2023-11-05 7/week @ 2023-11-12 12/week @ 2023-11-19 129/week @ 2023-11-26 73/week @ 2023-12-03 13/week @ 2023-12-10 8/week @ 2023-12-17 12/week @ 2023-12-24 116/week @ 2024-01-21 34/week @ 2024-01-28 1/week @ 2024-02-04

151 downloads per month

MIT license

13KB
181 lines

cdp-rs

Allows interacting with a browser using Chrome Dev Protocol. To use this you must launch an instance of Chrome with remote-debugging-port

chrome.exe --remote-debugging-port=9222

Examples

use cdp_rs::CdpClient;

// Connect to the first tab of your open Chrome instance
let mut cdp = CdpClient::new().connect_to_tab(0)

// Send a message so we can recieve DOM events
cdp.send("DOM.enable", parms!());
while Ok(m) = cdp.wait_message() {
    // Print out all messages recieved
    print!("Recieved: {}", m)
}
use cdp_rs::CdpClient;

// Connect to first tab to a chrome instance running on a non-default remote-debugging-port
let mut cdp = CdpClient::custom("localhost", 9000).connect_to_tab(0);
// Send message with parameters and recieve the response
let cookies = cdp.send("Network.getCookies", parms!("urls", vec!["https://www.google.com"]))?;
// Check cookies

lib.rs:

cdp-rs

cdp-rs is a Chrome Dev Protocol client, which allows interacting with a browser through the CDP protocol.

Dependencies

~5–18MB
~275K SLoC