"Simplicity is prerequisite for reliability" — Edsger Dijkstra
This is simplified fork of crates reqwest = {version = "0.11", features = ["blocking"]}
and scraper = "0.17.1"
which working together.
Also are system pub struct std::path::Path
, pub struct std::fs::File
and pub fn std::fs::File
.
```toml
[dependencies] scr = "1.0.0" ```
fn main() { let scraper = Scraper::new("scrapeme.live/shop/"); let element = scraper.get_el("main#main>ul>li.product>a>h2");
assert_eq!(element.inner_html(), "Bulbasaur")
}
- ### parse fragment of site
rust
use scr::Scraper;
fn main() { let scraper = Scraper::new("scrapeme.live/shop/"); let fragment = scraper.gettextonce("main#main>ul>li.product>a"); let newscraper = Scraper::fromfragment(fragment.asstr()); let element = newscraper.get_el("a");
assert_eq!(element.inner_html(), "Bulbasaur")
}
- ### download file
rust
use scr::FileLoader;
fn main() { let fileloader = FileLoader::new( "scrapeme.live/wp-content/uploads/2018/08/011.png", "./data/somepng.png" ).unwrap();
assert_eq!(
file_loader.file
.file_name().unwrap()
.to_str().unwrap(),
"some_png.png"
);
} ```