[−][src]Struct crabler::Element
Methods
impl Element
[src]
pub fn attr(&self, name: &str) -> Option<String>
[src]
Get value of an attribue
Arguments
name
- attribute name
Example
use crabquery::Document; let doc = Document::from("<a class='link'>hi there</a>"); let sel = doc.select("a"); let el = sel.first().unwrap(); assert_eq!(el.attr("class").unwrap(), "link");
pub fn tag(&self) -> Option<String>
[src]
Get tag value
Example
use crabquery::Document; let doc = Document::from("<a class='link'>hi there</a>"); let sel = doc.select("a"); let el = sel.first().unwrap(); assert_eq!(el.tag().unwrap(), "a");
pub fn text(&self) -> Option<String>
[src]
Get text
Example
use crabquery::Document; let doc = Document::from("<a class='link'>hi there</a>"); let sel = doc.select("a"); let el = sel.first().unwrap(); assert_eq!(el.text().unwrap(), "hi there");
pub fn children(&self) -> Vec<Element>
[src]
Get children elements
Example
use crabquery::Document; let doc = Document::from("<a class='link'><span>hi there</span></a>"); let sel = doc.select("a"); let el = sel.first().unwrap(); assert_eq!(el.children().first().unwrap().text().unwrap(), "hi there");
pub fn parent(&self) -> Option<Element>
[src]
Get parent element
Example
use crabquery::Document; let doc = Document::from("<a class='link'><span>hi there</span></a>"); let sel = doc.select("span"); let el = sel.first().unwrap(); assert_eq!(el.parent().unwrap().tag().unwrap(), "a");
pub fn select(&self, selector: &str) -> Vec<Element>
[src]
Select child elements using given css selector
Example
use crabquery::Document; let doc = Document::from("<span><a class='link'>hi there</a></span>"); let sel = doc.select("span"); let el = sel.first().unwrap(); let sel = el.select("a"); let a = sel.first().unwrap(); assert_eq!(a.attr("class").unwrap(), "link");
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Element
impl !Send for Element
impl !Sync for Element
impl Unpin for Element
impl !UnwindSafe for Element
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, 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>,