/// Helper function which scrapes match IDs and short names from the Cricbuzz homepage
///
/// # Arguments
/// * `html` - The HTML page
/// * `match_id_name` - A vector containing a tuple of match short name and ID
Helper function which scrapes match IDs and short names from the Cricbuzz homepage
Helper function which scrapes match IDs and short names from the Cricbuzz homepage
fn parse_all_live_matches_id_and_short_name(html: &str, match_id_name: &mut Vec<(String, String)>) {
    let doc = Html::parse_document(html);
    /* These unwraps will not panic */
    let nav_sel = Selector::parse("nav.cb-mat-mnu").unwrap();
    let sel_a = Selector::parse("a").unwrap();
    if let Some(nav) = doc.select(&nav_sel).next() {
        for link in nav.select(&sel_a) {
            let text = link
                .text()
                .collect::<Vec<&str>>()
                .concat()
                .trim()
                .to_string();
            if !text.is_empty() && !text.eq("MATCHES") {
                let words = text.split('-').collect::<Vec<&str>>();
                if words.len() >= 2 {
                    let status = words[1];
                    if status.trim().eq("Live") {
                        if let Some(href) = link.value().attr("href") {
                            let split_str = href.split('/').collect::<Vec<&str>>();
                            match_id_name
                                .push((words[0].trim().to_string(), split_str[2].to_string()));
                        }
                    }
                }
            }
        }
    }
}
fn parse_all_live_matches_id_and_short_name ( html : & str , match_id_name : & mut Vec < ( String , String ) > ) { let doc = Html :: parse_document ( html ) ; /* These unwraps will not panic */ let nav_sel = Selector :: parse ( " " ) . unwrap ( ) ; let sel_a = Selector :: parse ( " " ) . unwrap ( ) ; if let Some ( nav ) = doc . select ( & nav_sel ) . next ( ) { for link in nav . select ( & sel_a ) { let text = link . text ( ) . collect :: < Vec < & str > > ( ) . concat ( ) . trim ( ) . to_string ( ) ; if ! text . is_empty ( ) && ! text . eq ( " " ) { let words = text . split ( '-' ) . collect :: < Vec < & str > > ( ) ; if words . len ( ) >= 2 { let status = words [ 1 ] ; if status . trim ( ) . eq ( " " ) { if let Some ( href ) = link . value ( ) . attr ( " " ) { let split_str = href . split ( '/' ) . collect :: < Vec < & str > > ( ) ; match_id_name . push ( ( words [ 0 ] . trim ( ) . to_string ( ) , split_str [ 2 ] . to_string ( ) ) ) ; } } } } } } }
Helper function which scrapes match IDs and short names from the Cricbuzz homepage
Helper function which scrapes match IDs and short names from the Cricbuzz homepage
html
&str
match_id_name
&mut Vec<(String, String)>