Files
rust-imspyder/src/main.rs
2024-01-12 12:20:44 +08:00

32 lines
799 B
Rust

use std::str::FromStr;
use std::thread;
use std::time::Duration;
use bytes::Bytes;
mod file;
mod web_parser;
fn main() {
let mut continue_flag = true;
let mut idx: i32;
let index = file::read_file_string("cache/index").expect("Read index error");
if index.is_empty() {
idx = 1;
} else {
idx = i32::from_str(&index).expect("Index Corrupted");
}
while continue_flag {
let name = web_parser::get_title(idx);
if name == "" {
continue_flag = false;
} else {
web_parser::download_images(idx, &name);
idx += 1;
}
file::write_file("cache/index", Bytes::from(idx.to_string())).expect(&format!("Write index error: {}", idx));
thread::sleep(Duration::from_millis(300));
}
}