parse-book-source

Crates.ioparse-book-source
lib.rsparse-book-source
version0.1.6
created_at2024-12-10 07:03:40.732006+00
updated_at2025-01-17 03:59:28.635234+00
descriptionTerminal reader for novel
homepage
repositoryhttps://github.com/yexiyue/parse-book-source
max_upload_size
id1478182
size45,061
叶师傅 (yexiyue)

documentation

README

Parse Book Source

本仓库是为TRNovle 服务,用于支持解析各种书籍源。兼容部分阅读书源。

  • 支持解析 Api Json接口
  • 支持解析 网站源

示例

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(())
}

Commit count: 0

cargo fmt