Expand description
Page and browsing context management for isolated, parallel scraping
Each BrowserContext (future) is an incognito-style isolation boundary (separate
cookies, localStorage, cache). Each context can contain many PageHandles
(tabs). Both types clean up their CDP resources automatically on drop.
§Resource blocking
Pass a ResourceFilter to PageHandle::set_resource_filter to intercept
and block specific request types (images, fonts, CSS) before page load —
significantly reducing page load times for text-only scraping.
§Wait strategies
PageHandle exposes three wait strategies via WaitUntil:
DomContentLoaded— fires when the HTML is parsedNetworkIdle— fires when there are ≤2 in-flight requests for 500 msSelector(css)— fires when a CSS selector matches an element
§Example
use stygian_browser::{BrowserPool, BrowserConfig};
use stygian_browser::page::{ResourceFilter, WaitUntil};
use std::time::Duration;
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
let mut page = handle.browser().expect("valid browser").new_page().await?;
page.set_resource_filter(ResourceFilter::block_media()).await?;
page.navigate("https://example.com", WaitUntil::DomContentLoaded, Duration::from_secs(30)).await?;
let title = page.title().await?;
println!("title: {title}");
handle.release().await;Structs§
- Page
Handle - A handle to an open browser tab.
- Resource
Filter - Set of resource types to block from loading.
Enums§
- Resource
Type - CDP resource types that can be intercepted.
- Wait
Until - Condition to wait for after a navigation.