pub struct Soup { /* private fields */ }
Expand description
Parses HTML & provides methods to query & manipulate the document
Implementations§
Source§impl Soup
impl Soup
Sourcepub fn new(html: &str) -> Soup
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);
Sourcepub fn from_reader<R: Read>(reader: R) -> Result<Soup>
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)?;
Trait Implementations§
Source§impl QueryBuilderExt for Soup
impl QueryBuilderExt for Soup
Source§fn get_handle(&self) -> Handle
fn get_handle(&self) -> Handle
Retrieves the Handle that these methods will work on
Source§fn limit<'a>(&self, limit: usize) -> QueryBuilder<'a, (), ()>
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, (), ()>>
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,
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,
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, (), ()>>
fn attr<'a, P, Q>( &self, name: P, value: Q, ) -> QueryBuilder<'a, AttrQuery<P, Q>, QueryWrapper<'a, (), ()>>
Starts building a Query, with attr
attr
Source§fn class<'a, P: Pattern>(
&self,
value: P,
) -> QueryBuilder<'a, AttrQuery<&'static str, P>, QueryWrapper<'a, (), ()>>
fn class<'a, P: Pattern>( &self, value: P, ) -> QueryBuilder<'a, AttrQuery<&'static str, P>, QueryWrapper<'a, (), ()>>
Starts building a Query, with class
class
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more