[−][src]Struct scraper::html::Html
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
fn finish(self) -> Self
[src]
fn parse_error(&mut self, msg: Cow<'static, str>)
[src]
fn set_quirks_mode(&mut self, mode: QuirksMode)
[src]
fn get_document(&mut self) -> Self::Handle
[src]
fn same_node(&self, x: &Self::Handle, y: &Self::Handle) -> bool
[src]
fn elem_name(&self, target: &Self::Handle) -> ExpandedName
[src]
fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
_flags: ElementFlags
) -> Self::Handle
[src]
&mut self,
name: QualName,
attrs: Vec<Attribute>,
_flags: ElementFlags
) -> Self::Handle
fn create_comment(&mut self, text: StrTendril) -> Self::Handle
[src]
fn append_doctype_to_document(
&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril
)
[src]
&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril
)
fn append(&mut self, parent: &Self::Handle, child: NodeOrText<Self::Handle>)
[src]
fn append_before_sibling(
&mut self,
sibling: &Self::Handle,
new_node: NodeOrText<Self::Handle>
)
[src]
&mut self,
sibling: &Self::Handle,
new_node: NodeOrText<Self::Handle>
)
fn remove_from_parent(&mut self, target: &Self::Handle)
[src]
fn reparent_children(&mut self, node: &Self::Handle, new_parent: &Self::Handle)
[src]
fn add_attrs_if_missing(&mut self, target: &Self::Handle, attrs: Vec<Attribute>)
[src]
fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle
[src]
fn mark_script_already_started(&mut self, _node: &Self::Handle)
[src]
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Self::Handle
[src]
fn append_based_on_parent_node(
&mut self,
element: &Self::Handle,
prev_element: &Self::Handle,
child: NodeOrText<Self::Handle>
)
[src]
&mut self,
element: &Self::Handle,
prev_element: &Self::Handle,
child: NodeOrText<Self::Handle>
)
fn pop(&mut self, _node: &Self::Handle)
fn associate_with_form(
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
fn is_mathml_annotation_xml_integration_point(
&self,
_handle: &Self::Handle
) -> bool
&self,
_handle: &Self::Handle
) -> bool
fn set_current_line(&mut self, _line_number: u64)
fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,