Struct Soup

Source
pub struct Soup { /* private fields */ }
Expand description

Parses HTML & provides methods to query & manipulate the document

Implementations§

Source§

impl Soup

Source

pub fn new(html: &str) -> Soup

Create a new Soup instance from a string slice

§Example
let html = r#"
<!doctype html>
<html>
  <head>
    <title>page title</title>
  </head>
  <body>
    <h1>Heading</h1>
    <p>Some text</p>
    <p>Some more text</p>
  </body>
</html>
"#;

let soup = Soup::new(html);
Source

pub fn from_reader<R: Read>(reader: R) -> Result<Soup>

Create a new Soup instance from something that implements Read

This is good for parsing the output of an HTTP response, for example.

use soup::prelude::*;

let response = reqwest::get("https://docs.rs/soup")?;
let soup = Soup::from_reader(response)?;
Source

pub fn text(&self) -> String

Extracts all text from the HTML

Trait Implementations§

Source§

impl Debug for Soup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<RcDom> for Soup

Source§

fn from(rc: RcDom) -> Soup

Converts to this type from the input type.
Source§

impl QueryBuilderExt for Soup

Source§

fn get_handle(&self) -> Handle

Retrieves the Handle that these methods will work on
Source§

fn limit<'a>(&self, limit: usize) -> QueryBuilder<'a, (), ()>

Starts building a Query, with limit limit
Source§

fn tag<'a, P: Pattern>( &self, tag: P, ) -> QueryBuilder<'a, TagQuery<P>, QueryWrapper<'a, (), ()>>

Starts building a Query, with tag tag
Source§

fn attr_name<'a, P>( &self, name: P, ) -> QueryBuilder<'a, AttrQuery<P, bool>, QueryWrapper<'a, (), ()>>
where P: Pattern,

Starts building a Query, with attr name name
Source§

fn attr_value<'a, P>( &self, value: P, ) -> QueryBuilder<'a, AttrQuery<bool, P>, QueryWrapper<'a, (), ()>>
where P: Pattern,

Starts building a Query, with attr value value
Source§

fn attr<'a, P, Q>( &self, name: P, value: Q, ) -> QueryBuilder<'a, AttrQuery<P, Q>, QueryWrapper<'a, (), ()>>
where P: Pattern, Q: Pattern,

Starts building a Query, with attr attr
Source§

fn class<'a, P: Pattern>( &self, value: P, ) -> QueryBuilder<'a, AttrQuery<&'static str, P>, QueryWrapper<'a, (), ()>>

Starts building a Query, with class class
Source§

fn recursive<'a>(&self, recursive: bool) -> QueryBuilder<'a, (), ()>

Starts building a Query, with recursion set to recursive
Source§

fn children(&self) -> NodeChildIter

Returns an iterator over the node’s children Read more
Source§

fn parents(&self) -> NodeParentIter

Iterator over the parents of a node Read more

Auto Trait Implementations§

§

impl Freeze for Soup

§

impl !RefUnwindSafe for Soup

§

impl !Send for Soup

§

impl !Sync for Soup

§

impl Unpin for Soup

§

impl !UnwindSafe for Soup

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.