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) -> Fallible<Soup>
pub fn from_reader<R: Read>(reader: R) -> Fallible<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)?;
sourcepub fn limit(&self, limit: usize) -> QueryBuilder
pub fn limit(&self, limit: usize) -> QueryBuilder
Starts building a Query, with limit limit
sourcepub fn tag(&self, tag: &str) -> QueryBuilder
pub fn tag(&self, tag: &str) -> QueryBuilder
Starts building a Query, with tag tag
sourcepub fn attr(&self, name: &str, value: &str) -> QueryBuilder
pub fn attr(&self, name: &str, value: &str) -> QueryBuilder
Starts building a Query, with attr attr
sourcepub fn class(&self, value: &str) -> QueryBuilder
pub fn class(&self, value: &str) -> QueryBuilder
Starts building a Query, with class class