[][src]Struct scraper::html::Html

pub struct Html {
    pub errors: Vec<Cow<'static, str>>,
    pub quirks_mode: QuirksMode,
    pub tree: Tree<Node>,
}

An HTML tree.

Parsing does not fail hard. Instead, the quirks_mode is set and errors are added to the errors field. The tree will still be populated as best as possible.

Implements the TreeSink trait from the html5ever crate, which allows HTML to be parsed.

Fields

errors: Vec<Cow<'static, str>>

Parse errors.

quirks_mode: QuirksMode

The quirks mode.

tree: Tree<Node>

The node tree.

Methods

impl Html[src]

pub fn new_document() -> Self[src]

Creates an empty HTML document.

pub fn new_fragment() -> Self[src]

Creates an empty HTML fragment.

pub fn parse_document(document: &str) -> Self[src]

Parses a string of HTML as a document.

This is a convenience method for the following:

use html5ever::driver::{self, ParseOpts};
use scraper::Html;
use tendril::TendrilSink;

let parser = driver::parse_document(Html::new_document(), ParseOpts::default());
let html = parser.one(document);

pub fn parse_fragment(fragment: &str) -> Self[src]

Parses a string of HTML as a fragment.

pub fn select<'a, 'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>[src]

Returns an iterator over elements matching a selector.

pub fn root_element(&self) -> ElementRef[src]

Returns the root <html> element.

Trait Implementations

impl Clone for Html[src]

impl Debug for Html[src]

impl Eq for Html[src]

impl PartialEq<Html> for Html[src]

impl StructuralEq for Html[src]

impl StructuralPartialEq for Html[src]

impl TreeSink for Html[src]

Note: does not support the <template> element.

type Output = Self

The overall result of parsing. Read more

type Handle = NodeId

Handle is a reference to a DOM node. The tree builder requires that a Handle implements Clone to get another reference to the same node. Read more

Auto Trait Implementations

impl !RefUnwindSafe for Html

impl !Send for Html

impl !Sync for Html

impl Unpin for Html

impl UnwindSafe for Html

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.