pub async fn crawl_page_count(client: &Client, board: &BoardName) -> Result<u32, Error> {
    lazy_static! {
        static ref RE: Regex = Regex::new(r"index(?P<num>\d+)").unwrap();
    }

    info!("Start crawling page count of board {}", board);
    let latest_page_url = compose_page_url(&board, 0);
    let document = transform_to_document(client, &latest_page_url, None).await?;
    let last_page_url = match document
        .find(Name("a").and(Class("wide")))
        .find(|n| n.text() == "‹ 上頁")
    {
        Some(n) => n.attr("href").unwrap(),
        None => return Ok(1),
    };
    let count_until_last_page = RE
        .captures(last_page_url)
        .unwrap()
        .name("num")
        .unwrap()
        .as_str()
        .parse::<u32>()
        .unwrap();
    let page_count = count_until_last_page + 1;
    info!(
        "Finish crawling page count of board {}. page_count: {}",
        board, page_count
    );
    Ok(page_count)
}
/// Crawl the page count of given board.
Crawl the page count of given board.
Crawl the page count of given board .
pub async fn crawl_page_count(client: &Client, board: &BoardName) -> Result<u32, Error> {
    lazy_static! {
        static ref RE: Regex = Regex::new(r"index(?P<num>\d+)").unwrap();
    }
    info!("Start crawling page count of board {}", board);
    let latest_page_url = compose_page_url(&board, 0);
    let document = transform_to_document(client, &latest_page_url, None).await?;
    let last_page_url = match document
        .find(Name("a").and(Class("wide")))
        .find(|n| n.text() == "‹ 上頁")
    {
        Some(n) => n.attr("href").unwrap(),
        None => return Ok(1),
    };
    let count_until_last_page = RE
        .captures(last_page_url)
        .unwrap()
        .name("num")
        .unwrap()
        .as_str()
        .parse::<u32>()
        .unwrap();
    let page_count = count_until_last_page + 1;
    info!(
        "Finish crawling page count of board {}. page_count: {}",
        board, page_count
    );
    Ok(page_count)
}
pub async fn crawl_page_count ( client : & Client , board : & BoardName ) -> Result < u32 , Error > { lazy_static ! { static ref RE Regex Regex new ( r"index(?P<num>\d+)" ) unwrap ( ) } info ! ( " " board ) ; let latest_page_url = compose_page_url ( & board , 0 ) ; let document = transform_to_document ( client , & latest_page_url , None ) . await ? ; let last_page_url = match document . find ( Name ( " " ) . and ( Class ( " " ) ) ) . find ( | n | n . text ( ) == " { Some ( n ) => n . attr ( " " ) . unwrap ( ) , None => return Ok ( 1 ) , } ; let count_until_last_page = RE . captures ( last_page_url ) . unwrap ( ) . name ( " " ) . unwrap ( ) . as_str ( ) . parse :: < u32 > ( ) . unwrap ( ) ; let page_count = count_until_last_page + 1 ; info ! ( " " board page_count ) ; Ok ( page_count ) }
Crawl the page count of given board.
Crawl the page count of given board .
client
&Client
board
&BoardName