Add an example to the readme and test it
This commit is contained in:
parent
f1a4e2e819
commit
314bc347de
2 changed files with 22 additions and 2 deletions
14
README.md
14
README.md
|
@ -1,5 +1,15 @@
|
|||
# favicon-scraper
|
||||
|
||||
Scrapes favicons from websites.
|
||||
Scrapes favicons from websites. Does not particularly care for 100% optimal
|
||||
performance, it just needs to work.
|
||||
|
||||
Does not particularly care for 100% optimal performance, it just needs to work
|
||||
To get started, try the `scrape` function:
|
||||
|
||||
```rust
|
||||
use favicon_scraper::{scrape, Icon};
|
||||
|
||||
let icons: Vec<Icon> = scrape("https://google.com").await.unwrap();
|
||||
|
||||
// Should find something like "https://www.google.com/favicon.ico"
|
||||
println!("Google's icon can be found at {}", icons[0].url);
|
||||
```
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -92,4 +92,14 @@ mod tests {
|
|||
println!("Kind of icon: {:?}\n", icon.kind);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_readme_example() {
|
||||
use crate::{scrape, Icon};
|
||||
|
||||
let icons: Vec<Icon> = scrape("https://google.com").await.unwrap();
|
||||
|
||||
// Should find something like "https://www.google.com/favicon.ico"
|
||||
println!("Google's icon can be found at {}", icons[0].url);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue