Crates.io | scr |
lib.rs | scr |
version | 1.0.2 |
source | src |
created_at | 2023-08-15 19:54:06.353651 |
updated_at | 2023-08-21 08:31:29.608958 |
description | Most simple site parser and file loader |
homepage | |
repository | https://github.com/1kawdalg/scr |
max_upload_size | |
id | 945256 |
size | 12,774 |
"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::write
.
# Cargo.toml
[dependencies]
scr = "1.0.2"
use scr::Scraper;
fn main() {
let scraper = Scraper::new("scrapeme.live/shop/").unwrap();
let element = scraper.get_el("main#main>ul>li.product>a>h2").unwrap();
assert_eq!(element.inner_html(), "Bulbasaur")
}
use scr::Scraper;
fn main() {
let scraper = Scraper::new("scrapeme.live/shop/").unwrap();
let fragment = scraper.get_text_once("main#main>ul>li.product>a").unwrap();
let new_scraper = Scraper::from_fragment(fragment.as_str()).unwrap();
let element = new_scraper.get_el("a").unwrap();
assert_eq!(element.inner_html(), "Bulbasaur")
}
use scr::FileLoader;
fn main() {
let file_loader = FileLoader::new(
"scrapeme.live/wp-content/uploads/2018/08/011.png",
"./data/some_png.png"
).unwrap();
assert_eq!(
file_loader.file
.file_name().unwrap()
.to_str().unwrap(),
"some_png.png"
);
}