dyer 0.1.1-alpha

Dyer is designed for reliable, flexible and fast web-crawling, providing some high-level, comprehensive features without compromising speed. By means of event-driven, non-blocking I/O tokio and powerful, reliable [Rust programming
Documentation
use std::collections::HashMap;

/// some utilities that useful and convenience for dealing with data flow.

pub fn get_cookie(data: &str) -> HashMap<String, String> {
    let stop_word = ["path", "expires", "domain", "httponly"];
    let mut cookie = HashMap::new();
    let vals = data.split("::").collect::<Vec<&str>>();
    vals.into_iter().for_each(|val| {
        let v_str: Vec<&str> = val.split(";").map(|s| s.trim()).collect();
        v_str.into_iter().for_each(|pair| {
            let mut ind = true;
            let tmp: Vec<&str> = pair
                .split("=")
                .filter(|c| {
                    if !stop_word.contains(&c.to_lowercase().trim()) {
                        true
                    } else {
                        ind = false;
                        false
                    }
                })
                .collect();
            if ind {
                cookie.insert(tmp[0].to_string(), tmp[1..].join("="));
            }
        });
    });
    cookie
}