Struct scraper::html::Html [−][src]
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]
impl Html
pub fn new_document() -> Self
[src]
pub fn new_document() -> Self
Creates an empty HTML document.
pub fn new_fragment() -> Self
[src]
pub fn new_fragment() -> Self
Creates an empty HTML fragment.
pub fn parse_document(document: &str) -> Self
[src]
pub fn parse_document(document: &str) -> Self
Parses a string of HTML as a document.
pub fn parse_fragment(fragment: &str) -> Self
[src]
pub fn parse_fragment(fragment: &str) -> Self
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]
pub fn select<'a, 'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>
Returns an iterator over elements matching a selector.
Trait Implementations
impl TreeSink for Html
[src]
impl TreeSink for Html
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 finish(self) -> Self
Consume this sink and return the overall result of parsing. Read more
fn parse_error(&mut self, msg: Cow<'static, str>)
[src]
fn parse_error(&mut self, msg: Cow<'static, str>)
Signal a parse error.
fn set_quirks_mode(&mut self, mode: QuirksMode)
[src]
fn set_quirks_mode(&mut self, mode: QuirksMode)
Set the document's quirks mode.
fn get_document(&mut self) -> Self::Handle
[src]
fn get_document(&mut self) -> Self::Handle
Get a handle to the Document
node.
fn same_node(&self, x: &Self::Handle, y: &Self::Handle) -> bool
[src]
fn same_node(&self, x: &Self::Handle, y: &Self::Handle) -> bool
Do two handles refer to the same node?
fn elem_name(&self, target: &Self::Handle) -> ExpandedName
[src]
fn elem_name(&self, target: &Self::Handle) -> ExpandedName
What is the name of this element? Read more
fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
_flags: ElementFlags
) -> Self::Handle
[src]
fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
_flags: ElementFlags
) -> Self::Handle
Create an element. Read more
fn create_comment(&mut self, text: StrTendril) -> Self::Handle
[src]
fn create_comment(&mut self, text: StrTendril) -> Self::Handle
Create a comment node.
fn append_doctype_to_document(
&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril
)
[src]
fn append_doctype_to_document(
&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril
)
Append a DOCTYPE
element to the Document
node.
fn append(&mut self, parent: &Self::Handle, child: NodeOrText<Self::Handle>)
[src]
fn append(&mut self, parent: &Self::Handle, child: NodeOrText<Self::Handle>)
Append a node as the last child of the given node. If this would produce adjacent sibling text nodes, it should concatenate the text instead. Read more
fn append_before_sibling(
&mut self,
sibling: &Self::Handle,
new_node: NodeOrText<Self::Handle>
)
[src]
fn append_before_sibling(
&mut self,
sibling: &Self::Handle,
new_node: NodeOrText<Self::Handle>
)
Append a node as the sibling immediately before the given node. Read more
fn remove_from_parent(&mut self, target: &Self::Handle)
[src]
fn remove_from_parent(&mut self, target: &Self::Handle)
Detach the given node from its parent.
fn reparent_children(&mut self, node: &Self::Handle, new_parent: &Self::Handle)
[src]
fn reparent_children(&mut self, node: &Self::Handle, new_parent: &Self::Handle)
Remove all the children from node and append them to new_parent.
fn add_attrs_if_missing(&mut self, target: &Self::Handle, attrs: Vec<Attribute>)
[src]
fn add_attrs_if_missing(&mut self, target: &Self::Handle, attrs: Vec<Attribute>)
Add each attribute to the given element, if no attribute with that name already exists. The tree builder promises this will never be called with something else than an element. Read more
fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle
[src]
fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle
Get a handle to a template's template contents. The tree builder promises this will never be called with something else than a template element. Read more
fn mark_script_already_started(&mut self, _node: &Self::Handle)
[src]
fn mark_script_already_started(&mut self, _node: &Self::Handle)
Mark a HTML <script>
as "already started".
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Self::Handle
[src]
fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> Self::Handle
Create a Processing Instruction node.
fn append_based_on_parent_node(
&mut self,
element: &Self::Handle,
prev_element: &Self::Handle,
child: NodeOrText<Self::Handle>
)
[src]
fn append_based_on_parent_node(
&mut self,
element: &Self::Handle,
prev_element: &Self::Handle,
child: NodeOrText<Self::Handle>
)
When the insertion point is decided by the existence of a parent node of the element, we consider both possibilities and send the element which will be used if a parent node exists, along with the element to be used if there isn't one. Read more
fn pop(&mut self, _node: &Self::Handle)
fn pop(&mut self, _node: &Self::Handle)
Indicate that a node was popped off the stack of open elements.
fn associate_with_form(
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
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
fn is_mathml_annotation_xml_integration_point(
&self,
_handle: &Self::Handle
) -> bool
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
fn set_current_line(&mut self, _line_number: u64)
fn set_current_line(&mut self, _line_number: u64)
Called whenever the line number changes.
fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
Indicate that a script
element is complete.
impl Debug for Html
[src]
impl Debug for Html
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Html
[src]
impl Clone for Html
fn clone(&self) -> Html
[src]
fn clone(&self) -> Html
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Html
[src]
impl PartialEq for Html
fn eq(&self, other: &Html) -> bool
[src]
fn eq(&self, other: &Html) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Html) -> bool
[src]
fn ne(&self, other: &Html) -> bool
This method tests for !=
.
impl Eq for Html
[src]
impl Eq for Html