36 lines
856 B
Rust
36 lines
856 B
Rust
mod db;
|
|
mod parse;
|
|
mod types;
|
|
use std::{fs::File, io::Read};
|
|
|
|
use parse::parse;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
env_logger::init();
|
|
let html = read("test_mordit.html")?;
|
|
parse(&html);
|
|
Ok(())
|
|
}
|
|
|
|
fn _download_file(url: &str, _path: &str) -> Result<String, Box<dyn std::error::Error>> {
|
|
// Some simple CLI args requirements...
|
|
|
|
eprintln!("Fetching {url:?}...");
|
|
|
|
// reqwest::blocking::get() is a convenience function.
|
|
//
|
|
// In most cases, you should create/build a reqwest::Client and reuse
|
|
// it for all requests.
|
|
let res = reqwest::blocking::get(url)?;
|
|
|
|
let body = res.text()?;
|
|
Ok(body)
|
|
}
|
|
|
|
fn read(path: &str) -> Result<String, std::io::Error> {
|
|
let mut file = File::open(path)?;
|
|
let mut contents = String::new();
|
|
file.read_to_string(&mut contents)?;
|
|
Ok(contents)
|
|
}
|