7 releases

new 0.1.6 Jan 17, 2025
0.1.5 Jan 9, 2025
0.1.2 Dec 18, 2024

#1684 in Parser implementations

Download history 181/week @ 2024-12-08 286/week @ 2024-12-15 18/week @ 2024-12-22 453/week @ 2025-01-05 132/week @ 2025-01-12

626 downloads per month
Used in trnovel

MIT license

46KB
1K SLoC

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

Dependencies

~13–27MB
~384K SLoC