Expand description
Typed DOM extraction via Extract derive macro.
§Example
ⓘ
use stygian_browser::extract::Extract;
use stygian_browser::{BrowserPool, BrowserConfig, WaitUntil};
use std::time::Duration;
#[derive(Extract)]
struct Headline {
#[selector("h2.headline")]
title: String,
#[selector("a.link")]
link: Option<String>,
}
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
let mut page = handle.browser().expect("valid browser").new_page().await?;
page.navigate(
"https://example.com",
WaitUntil::DomContentLoaded,
Duration::from_secs(30),
).await?;
let items: Vec<Headline> = page.extract_all::<Headline>("article").await?;Enums§
- Extraction
Error - An error produced during
#[derive(Extract)]-driven extraction.
Traits§
- Extractable
- Types that can be extracted from a live DOM
crate::page::NodeHandle.
Derive Macros§
- Extract
- Derive
stygian_browser::extract::Extractablefor a struct.