pub struct SelectorNode { /* private fields */ }Expand description
A node selected from an HTML document using the builtin CSS selector API.
Implementations§
Source§impl SelectorNode
impl SelectorNode
Sourcepub fn css(&self, query: &str) -> Result<SelectorList, SpiderError>
pub fn css(&self, query: &str) -> Result<SelectorList, SpiderError>
Applies a CSS selector relative to this node.
§Errors
Returns SpiderError::HtmlParseError when the selector is invalid or
when chaining from a text/attribute extraction.
Sourcepub fn get_all(&self) -> Vec<String>
pub fn get_all(&self) -> Vec<String>
Returns this node’s extracted value as a single-element vector or an empty one.
Sourcepub fn attrib(&self, name: &str) -> Option<String>
pub fn attrib(&self, name: &str) -> Option<String>
Returns the named attribute from the selected element.
Sourcepub fn text_content(&self) -> Option<String>
pub fn text_content(&self) -> Option<String>
Returns the concatenated text content of the selected element.
Sourcepub fn has_css(&self, query: &str) -> Result<bool, SpiderError>
pub fn has_css(&self, query: &str) -> Result<bool, SpiderError>
Returns true when this element has any descendant matching query.
§Errors
Returns SpiderError::HtmlParseError when the selector is invalid or
when called on a text/attribute extraction.
Sourcepub fn has_ancestor(&self, query: &str) -> Result<bool, SpiderError>
pub fn has_ancestor(&self, query: &str) -> Result<bool, SpiderError>
Returns true when any ancestor of this element matches query.
§Errors
Returns SpiderError::HtmlParseError when the selector is invalid or
when called on a text/attribute extraction.
Trait Implementations§
Source§impl Clone for SelectorNode
impl Clone for SelectorNode
Source§fn clone(&self) -> SelectorNode
fn clone(&self) -> SelectorNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more