pub struct SessionRecorder { /* private fields */ }Expand description
Records CDP events and network traffic during a browser session.
Create one per scraping job, call record_event for
each CDP event you want to log, then call stop and
export_har when the session ends.
Implementations§
Source§impl SessionRecorder
impl SessionRecorder
Sourcepub fn start(config: RecorderConfig) -> Self
pub fn start(config: RecorderConfig) -> Self
Start a new recorder with the given config.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true if the recorder is currently running.
Sourcepub fn record_event(&self, method: &str, params: Value)
pub fn record_event(&self, method: &str, params: Value)
Record a raw CDP event by method name and parameters.
Call this for every CDP event you receive from the browser.
The recorder automatically tracks Network.requestWillBeSent and
Network.responseReceived events to build HAR entries.
Sourcepub fn export_event_log(&self, path: impl AsRef<Path>) -> Result<()>
pub fn export_event_log(&self, path: impl AsRef<Path>) -> Result<()>
Export the buffered CDP event log as a newline-delimited JSON file.
§Errors
Returns an IO error if the file cannot be written.
Sourcepub fn export_har(&self, path: impl AsRef<Path>) -> Result<()>
pub fn export_har(&self, path: impl AsRef<Path>) -> Result<()>
Export captured network transactions as a HAR 1.2 file.
§Errors
Returns an IO or serialisation error if the file cannot be written.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Return the number of buffered CDP events.
Sourcepub fn network_entry_count(&self) -> usize
pub fn network_entry_count(&self) -> usize
Return the number of completed network entries.