Module page

Module page 

Source
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 parsed
  • NetworkIdle — fires when there are ≤2 in-flight requests for 500 ms
  • Selector(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§

PageHandle
A handle to an open browser tab.
ResourceFilter
Set of resource types to block from loading.

Enums§

ResourceType
CDP resource types that can be intercepted.
WaitUntil
Condition to wait for after a navigation.