Enum kalosm_language::context::Page
source · pub enum Page {
Static(StaticPage),
Dynamic(Tab),
}
Expand description
A page that is either static or dynamic.
§Example
use kalosm_language::prelude::*;
#[tokio::main]
async fn main() {
let page = Page::new(
Url::parse("https://www.nytimes.com/live/2023/09/21/world/zelensky-russia-ukraine-news").unwrap(),
BrowserMode::Static,
).unwrap();
let document = page.article().await.unwrap();
println!("Title: {}", document.title());
println!("Body: {}", document.body());
}
Variants§
Implementations§
source§impl Page
impl Page
sourcepub fn new(url: Url, mode: BrowserMode) -> Result<Self>
pub fn new(url: Url, mode: BrowserMode) -> Result<Self>
Create a new page at the given URL.
sourcepub async fn get_node(&self, node_ref: NodeRef) -> Result<AnyNode<'_>>
pub async fn get_node(&self, node_ref: NodeRef) -> Result<AnyNode<'_>>
Get the node with the given ID.
sourcepub async fn select_elements(&self, selector: &str) -> Result<Vec<AnyNode<'_>>>
pub async fn select_elements(&self, selector: &str) -> Result<Vec<AnyNode<'_>>>
Find all elements matching the given selector.
sourcepub fn screenshot(&self) -> Result<DynamicImage>
pub fn screenshot(&self) -> Result<DynamicImage>
Take a screenshot of the page if it is in a headless browser.
sourcepub async fn crawl(
start: Url,
mode: BrowserMode,
visit: impl CrawlingCallback
) -> Result<()>
pub async fn crawl( start: Url, mode: BrowserMode, visit: impl CrawlingCallback ) -> Result<()>
Start crawling from this page.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Page
impl Send for Page
impl !Sync for Page
impl Unpin for Page
impl !UnwindSafe for Page
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more