[][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.

Important traits for Select<'a, 'b>
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]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<Html> for Html[src]

impl Eq for Html[src]

impl Debug 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

default fn pop(&mut self, _node: &Self::Handle)

Indicate that a node was popped off the stack of open elements.

default fn associate_with_form(
    &mut self,
    _target: &Self::Handle,
    _form: &Self::Handle,
    _nodes: (&Self::Handle, Option<&Self::Handle>)
)

Associate the given form-associatable element with the form element

default fn is_mathml_annotation_xml_integration_point(
    &self,
    _handle: &Self::Handle
) -> bool

Returns true if the adjusted current node is an HTML integration point and the token is a start tag. Read more

default fn set_current_line(&mut self, _line_number: u64)

Called whenever the line number changes.

default fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState

Indicate that a script element is complete.

Auto Trait Implementations

impl !Send for Html

impl !Sync for Html

Blanket Implementations

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

type Owned = T

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.