pub struct StealthySession { /* private fields */ }Expand description
Anti-detection browser automation session with optional Cloudflare challenge solving.
StealthySession is the stealth counterpart to DynamicSession. It uses the
same Playwright infrastructure but launches Chromium with additional flags that
remove automation indicators, block WebRTC IP leaks, inject canvas noise, and
disable WebGL. It also includes a built-in Cloudflare Turnstile solver that
detects non-interactive, managed, interactive, and embedded challenges and
attempts to click through them automatically.
Implementations§
Source§impl StealthySession
impl StealthySession
Sourcepub fn new(config: StealthConfig) -> Result<Self>
pub fn new(config: StealthConfig) -> Result<Self>
Create a new StealthySession 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 with stealth flags and create the initial browser context.
This works like DynamicSession::start but additionally applies the
stealth CLI flags from StealthConfig::extra_stealth_args and the
full [constants::STEALTH_ARGS] list. 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 with stealth measures, solve challenges if enabled, and return the response.
If solve_cloudflare is enabled (either in the config or the per-request params),
the Cloudflare Turnstile solver runs after navigation. The method retries up to
config.base.retries times on failure.
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.