- let resp = client.get(&url).send()?;
-
- if resp.status().is_success() {
- let html = resp.text()?;
- let document = Html::parse_document(&html);
-
- // A vector of (<title>, <url>), empty if nothing matches.
- let match_items: Vec<(String, String)> =
- document.select(&selector).filter_map(
- |element| {
- if let (Some(title), Some(url_to_item)) = (element.value().attr("title"), element.value().attr("href")) {
- if title.find(to_match).is_some() {
- return Some((String::from(title), String::from(url_to_item)))
+
+ match client.get(&url).send() {
+ Ok(resp) =>
+ if resp.status().is_success() {
+ let html = resp.text()?;
+ let document = Html::parse_document(&html);
+
+ // A vector of (<title>, <url>), empty if nothing matches.
+ let match_items: Vec<(String, String)> =
+ document.select(&selector).filter_map(
+ |element| {
+ if let (Some(title), Some(url_to_item)) = (element.value().attr("title"), element.value().attr("href")) {
+ if title.find(to_match).is_some() {
+ return Some((String::from(title), String::from(url_to_item)))
+ }
+ }
+ None