コード例 #1
0
        /// <summary>
        /// 读取招聘详细信息
        /// </summary>
        /// <param name="dicData"></param>
        /// <returns></returns>
        private string GetZhaoPinInfo(Dictionary <string, Dictionary <string, string> > dicData)
        {
            Dictionary <string, string> dic     = dicData["sub"];
            Dictionary <string, string> dic_obj = dicData["obj"];
            var key           = GetDicKeyValue(dic, "inp_key") ?? ".net";
            var city          = GetDicKeyValue(dic, "sel_city") ?? "上海";
            var chk_zhilian   = GetDicKeyValue(dic, "chk_zhilian") ?? "False";
            var chk_liepin    = GetDicKeyValue(dic, "chk_liepin") ?? "False";
            var chk_qiancheng = GetDicKeyValue(dic, "chk_qiancheng") ?? "False";
            var chk_lashou    = GetDicKeyValue(dic, "chk_lashou") ?? "False";
            var index         = GetDicKeyValue(dic_obj, "index") ?? "1";

            var city_liepin    = DataClass.GetDic_liepin(city);
            var city_qiancheng = DataClass.GetDic_qiancheng(city);
            var city_zhilian   = DataClass.GetDic_zhilian(city);

            string url_智联招聘 = string.Format("http://sou.zhaopin.com/jobs/searchresult.ashx?jl={0}&kw={1}&p={2}", city_zhilian, key, index);
            string url_猎聘网  = string.Format("http://www.liepin.com/zhaopin/?key={0}&dqs={1}&curPage={2}", key, city_liepin, index);
            string url_前程无忧 = string.Format("http://search.51job.com/jobsearch/search_result.php?jobarea={0}&keyword={1}&curr_page={2}&fromJs=1", city_qiancheng, key, index);
            //            string url_拉勾网 = string.Format("http://www.lagou.com/jobs/list_{0}?city={1}&pn={2}", key, city_zhilian, index);//city_zhilian  这里和智联一样直接用的中文地址码
            string url_拉勾网 = string.Format("http://www.lagou.com/jobs/positionAjax.json?city={0}", city_zhilian);

            List <ZhaopinInfo> zpInfoList = new List <ZhaopinInfo>();
            MyHttpClient       client     = new MyHttpClient();

            try
            {
                if (chk_zhilian == "True")
                {
                    client.GetRequest(ref zpInfoList, url_智联招聘, ZhaopinType.智联招聘);
                }
                if (chk_liepin == "True")
                {
                    client.GetRequest(ref zpInfoList, url_猎聘网, ZhaopinType.猎聘网);
                }
                if (chk_qiancheng == "True")
                {
                    client.GetRequest(ref zpInfoList, url_前程无忧, ZhaopinType.前程无忧);
                }
                if (chk_lashou == "True")
                {
                    client.GetRequest(ref zpInfoList, url_拉勾网, ZhaopinType.拉勾网, index, key);
                }
            }
            catch (Exception)
            { }

            return(zpInfoList.ToJson());
        }
コード例 #2
0
        private string GetZhaoPinInfo(Dictionary <string, Dictionary <string, string> > dicData)
        {
            Dictionary <string, string> dic     = dicData["sub"];
            Dictionary <string, string> dic_obj = dicData["obj"];
            var key = ".net";

            if (dic.Keys.Contains("inp_key"))
            {
                key = string.IsNullOrEmpty(dic["inp_key"]) ? key : dic["inp_key"];
            }
            var city = "上海";

            if (dic.Keys.Contains("sel_city"))
            {
                city = string.IsNullOrEmpty(dic["sel_city"]) ? city : dic["sel_city"];
            }
            var index = "1";

            if (dic_obj.Keys.Contains("index"))
            {
                index = string.IsNullOrEmpty(dic_obj["index"]) ? city : dic_obj["index"];
            }

            var chk_zhilian = "False";

            if (dic.Keys.Contains("chk_zhilian"))
            {
                chk_zhilian = string.IsNullOrEmpty(dic["chk_zhilian"]) ? city : dic["chk_zhilian"];
            }
            var chk_liepin = "False";

            if (dic.Keys.Contains("chk_liepin"))
            {
                chk_liepin = string.IsNullOrEmpty(dic["chk_liepin"]) ? city : dic["chk_liepin"];
            }
            var chk_qiancheng = "False";

            if (dic.Keys.Contains("chk_qiancheng"))
            {
                chk_qiancheng = string.IsNullOrEmpty(dic["chk_qiancheng"]) ? city : dic["chk_qiancheng"];
            }

            var city_liepin    = DataClass.GetDic_liepin(city);
            var city_qiancheng = DataClass.GetDic_qiancheng(city);
            var city_zhilian   = DataClass.GetDic_zhilian(city);

            string url_智联招聘 = string.Format("http://sou.zhaopin.com/jobs/searchresult.ashx?jl={0}&kw={1}&p={2}", city_zhilian, key, index);
            string url_猎聘网  = string.Format("http://www.liepin.com/zhaopin/?key={0}&dqs={1}&curPage={2}", key, city_liepin, index);
            string url_前程无忧 = string.Format("http://search.51com/jobsearch/search_result.php?jobarea={0}&keyword={1}&curr_page={2}", city_qiancheng, key, index);

            List <ZhaopinInfo> zpInfoList = new List <ZhaopinInfo>();
            MyHttpClient       client     = new MyHttpClient();

            try
            {
                if (chk_zhilian == "True")
                {
                    client.GetRequest(ref zpInfoList, url_智联招聘, ZhaopinType.智联招聘);
                }
                if (chk_liepin == "True")
                {
                    client.GetRequest(ref zpInfoList, url_猎聘网, ZhaopinType.猎聘网);
                }
                if (chk_qiancheng == "True")
                {
                    client.GetRequest(ref zpInfoList, url_前程无忧, ZhaopinType.前程无忧);
                }
            }
            catch (Exception)
            { }

            return(zpInfoList.ToJson());
        }