pub struct DynamicSession { /* private fields */ }Expand description
Standard Playwright browser automation session without stealth measures.
DynamicSession manages the full lifecycle of a Chromium browser: launching the
Playwright driver, creating a browser context with cookies and init scripts,
navigating to pages, waiting for load events, and extracting the rendered HTML
into a Response. It supports static proxies, rotating proxies, CDP connections,
resource blocking, domain blocking, and custom page callbacks.
For sites with bot detection, use StealthySession instead.
Implementations§
Source§impl DynamicSession
impl DynamicSession
Sourcepub fn new(config: BrowserConfig) -> Result<Self>
pub fn new(config: BrowserConfig) -> Result<Self>
Create a new DynamicSession from the given configuration, validating it upfront.
The browser is not launched yet – call start to do that.
Returns an error if the configuration fails validation.
Sourcepub async fn start(&mut self) -> Result<()>
pub async fn start(&mut self) -> Result<()>
Launch the browser and create the initial browser context.
Depending on the configuration this will either launch a new Chromium process,
connect to an existing one via CDP, or launch with a rotating proxy provider.
Init scripts and cookies from the config are applied to the context.
You must call this before calling fetch.
Sourcepub async fn fetch(
&self,
url: &str,
params: Option<FetchParams>,
) -> Result<Response>
pub async fn fetch( &self, url: &str, params: Option<FetchParams>, ) -> Result<Response>
Navigate to url, wait for stability, and return the page response with retries.
Pass an optional FetchParams to override session-level settings for this
single request. The method retries up to config.retries times on failure,
sleeping config.retry_delay_secs between attempts.
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Returns true if the session has been started and not yet closed.
Use this to guard against calling fetch on a session that has not been
started or has already been shut down.
Sourcepub fn pool_stats(&self) -> PoolStats
pub fn pool_stats(&self) -> PoolStats
Return a snapshot of the page pool’s current statistics.
See PoolStats for what is included.