| Crates.io | parse-book-source |
| lib.rs | parse-book-source |
| version | 0.1.6 |
| created_at | 2024-12-10 07:03:40.732006+00 |
| updated_at | 2025-01-17 03:59:28.635234+00 |
| description | Terminal reader for novel |
| homepage | |
| repository | https://github.com/yexiyue/parse-book-source |
| max_upload_size | |
| id | 1478182 |
| size | 45,061 |
本仓库是为TRNovle 服务,用于支持解析各种书籍源。兼容部分阅读书源。
示例
use std::{thread::sleep, time::Duration};
use parse_book_source::{BookSource, BookSourceParser};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let book_source = BookSource::from_path(
"./test.json",
)?[0]
.clone();
let mut parser = BookSourceParser::new(book_source)?;
// let res = parser.search_books("百炼", 1, 2).await?;
// println!("{:#?}", res);
let explores = parser.get_explores().await?;
let res = parser.explore_books(&explores[0].url, 1, 2).await?;
println!("{:#?}", res);
let book_info = parser.get_book_info(&res[2].book_url).await?;
println!("{:#?}", book_info);
// sleep(Duration::from_secs(1));
let toc = parser.get_chapters(&book_info.toc_url).await?;
println!("{:#?}", toc);
// sleep(Duration::from_secs(1));
// let content = parser.get_content(&toc[1].chapter_url).await?;
// println!("{}", toc[1].chapter_url);
// println!("{}", content);
Ok(())
}