-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Ch. 17: rewrite the opening example
- Add `reqwest` and `scraper` dependencies to the `trpl` crate.
- Loading branch information
1 parent
6f5773e
commit d141a02
Showing
25 changed files
with
10,927 additions
and
286 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,3 @@ fn main() { | |
// ANCHOR_END: with-move | ||
}); | ||
} | ||
// ANCHOR_END: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "listing-scraper-01" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
trpl = { path = "../../../packages/trpl" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extern crate trpl; // required for mdbook test | ||
|
||
fn main() { | ||
// TODO: we'll add this next! | ||
} | ||
|
||
// ANCHOR: all | ||
use trpl::Html; | ||
|
||
async fn page_title_for(url: &str) -> Option<String> { | ||
let response = trpl::get(url).await; | ||
let response_text = response.text().await; | ||
Html::parse(&response_text) | ||
.select_first("title") | ||
.map(|title| title.inner_html()) | ||
} | ||
// ANCHOR_END: all |
Oops, something went wrong.