df-helper 0.2.26

df helper tools db cache
Documentation
#[cfg(test)]
mod tests {
    use json::object;
    use df_helper::http::http::Http;


    #[test]
    fn post() {
        let data = Http::url("https://api.weixin.qq.com/cgi-bin/openapi/quota/get?access_token=123123")
            .post(object! {
                "access_token":"123123",
                "cgi_path":""
        }).response();
        println!("{:#}", data);
    }

    #[test]
    fn down() {
        let url = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farchive%2Fb9e640e224737026a006973c7a5e907f08a88a51.jpg&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1667733351&t=41a0c9eecd8ecfcf63af97607cb8ea14";
        let data = Http::url(url).download("tests/file/test.jpeg").response();
        println!("{:#}", data);
    }

    #[test]
    fn now() {
        let data = Http::url("https://pic.rmb.bdstatic.com/bjh/down/ba168eeabeb536ede701cc180e7d5d2b.jpeg?x-bce-process=image/watermark,bucket_baidu-rmb-video-cover-1,image_YmpoL25ld3MvNjUzZjZkMjRlMDJiNjdjZWU1NzEzODg0MDNhYTQ0YzQucG5n,type_RlpMYW5UaW5nSGVpU01HQg==,w_12,text_QOiDluWTpeS9k-iCsg==,size_12,x_9,y_9,interval_2,color_FFFFFF,effect_softoutline,shc_000000,blr_2,align_1")
            .download("tests/file/tests.jpeg").response();
        println!("{:#}", data);
    }

    #[test]
    fn ttt() {
        let data = Http::url("https://geoapi.qweather.com/v2/city/lookup?key=fca4b8b60910418990427006fb10dbd1&location=beij")
            .get(object! {}).response();
        println!("{:#}", data);
    }

    #[test]
    fn tttttt() {
        let data = Http::url("http://hd.chinatax.gov.cn/service/findChukou.do")
            .post_form(object! {
                page:0,
                code:"",
                name:"",
            }).response();
        println!("{:#}", data);
    }

    #[test]
    fn get() {
        let mut http = Http::url("https://weixin.qq.com");
        let _data = http.get(object! {}).response();
        println!("{:#}", http.res_cookies);
    }

    #[test]
    fn cookies() {
        let mut http = Http::url("https://weixin.qq.com");
        let _data = http.set_cookies("tt", "123123").set_cookies("vvv", "33333").get(object! {}).response();
        println!("{:#}", http.res_cookies);
    }

    #[test]
    fn lookup() {
        let data = Http::url("https://geoapi.qweather.com/v2/city/lookup")
            .get(object! {
                key:"fca4b8b60910418990427006fb10dbd1",
                location:"chengdu"
            }).response();
        println!("{:#}", data["location"]);
    }

    #[test]
    fn air() {
        let data = Http::url("https://devapi.qweather.com/v7/air/now")
            .get(object! {
                key:"fca4b8b60910418990427006fb10dbd1",
                location:"101270101"
            }).response();
        println!("{:#}", data);
    }

    #[test]
    fn indices() {
        let data = Http::url("https://devapi.qweather.com/v7/indices/1d")
            .get(object! {
                key:"fca4b8b60910418990427006fb10dbd1",
                location:"101270101",
                type:0
            }).response();
        println!("{:#}", data);
    }

    #[test]
    fn weather() {
        let data = Http::url("https://devapi.qweather.com/v7/weather/now")
            .get(object! {
                key:"fca4b8b60910418990427006fb10dbd1",
                location:"101270101",
            }).response();
        println!("{:#}", data);
    }

    #[test]
    fn weather_7d() {
        let data = Http::url("https://devapi.qweather.com/v7/weather/7d")
            .get(object! {
                key:"fca4b8b60910418990427006fb10dbd1",
                location:"101270101",
            }).response();
        println!("{:#}", data);
    }

    #[test]
    fn grid_weather() {
        let data = Http::url("https://devapi.qweather.com/v7/grid-weather/now")
            .get(object! {
                location:"104.068882,30.662077",
                key:"fca4b8b60910418990427006fb10dbd1",
            }).response();
        println!("{:#}", data);
    }
}