Add an example to the readme and test it

This commit is contained in:
CenTdemeern1 2025-02-02 23:19:30 +01:00
parent f1a4e2e819
commit 314bc347de
2 changed files with 22 additions and 2 deletions

View file

@ -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);
```

View file

@ -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);
}
}