Parser

Trait Parser 

Source
pub trait Parser: Sealed {
    // Required method
    fn parse_with_config(
        &self,
        html: &str,
        config: &ParseConfig,
    ) -> ParseResult<Document>;

    // Provided method
    fn parse(&self, html: &str) -> ParseResult<Document> { ... }
}
Expand description

A sealed trait for HTML parsers.

This trait is sealed and cannot be implemented outside of this crate. Use Html5everParser for spec-compliant HTML5 parsing.

§Example

use scrape_core::{Html5everParser, Parser, ParseConfig};

let parser = Html5everParser;
let document = parser.parse("<html><body>Hello</body></html>")?;

Required Methods§

Source

fn parse_with_config( &self, html: &str, config: &ParseConfig, ) -> ParseResult<Document>

Parses HTML with the given configuration.

§Errors

Returns ParseError if parsing fails:

Provided Methods§

Source

fn parse(&self, html: &str) -> ParseResult<Document>

Parses HTML with default configuration.

§Errors

Returns ParseError::EmptyInput if the input is empty or whitespace-only.

Implementors§