Example #1
0
 public void GetJobListFromWeb()
 {
     try
     {
         var htmlWeb = new HtmlWeb { OverrideEncoding = Encoding.GetEncoding("UTF-8") };
         HtmlDocument htmlDoc =
             htmlWeb.Load(string.Format("http://sou.zhaopin.com/jobs/searchresult.ashx?jl={0}&kw={1}&p={2}",
                 DataClass.GetDic_zhilian(_pars.Addr), _pars.Key, _pars.Page));
         var nodeList =
             htmlDoc.DocumentNode.SelectNodes("//*[@id='newlist_list_content_table']/table[@class='newlist']")
                 .AsParallel()
                 .ToList();
         for (int i = 1; i < nodeList.Count; i++)
         {
             var node = nodeList[i];
             var job = new JobInfo();
             job.TitleName = node.SelectSingleNode(".//tr/td[@class='zwmc']/div/a").InnerText;
             job.InfoUrl = node.SelectSingleNode(".//tr/td[@class='zwmc']/div/a").Attributes["href"].Value;
             job.Company = node.SelectSingleNode(".//tr/td[@class='gsmc']/a").InnerText;
             job.Salary = node.SelectSingleNode(".//tr/td[@class='zwyx']").InnerText;
             job.City = node.SelectSingleNode(".//tr/td[@class='gzdd']").InnerText;
             job.Date = node.SelectSingleNode(".//tr/td[@class='gxsj']/span").InnerText;
             job.Source = "智联招聘";
             job.Method = "月薪";
             _jobList.Add(job);
         }
     }
     catch (Exception ex)
     {
         LogSave.ErrLogSave("错误【解析】", ex);
     }
 }
Example #2
0
        public void GetJobListFromWeb()
        {
            try
            {
                var htmlWeb = new HtmlWeb { OverrideEncoding = Encoding.GetEncoding("UTF-8") };

                HtmlDocument htmlDoc =
                    htmlWeb.Load(string.Format("http://www.liepin.com/zhaopin/?key={0}&dqs={1}&curPage={2}", _pars.Key,
                        DataClass.GetDic_liepin(_pars.Addr), _pars.Page));

                var nodeList =
                    htmlDoc.DocumentNode.SelectNodes("//ul[@class='sojob-result-list']/li ").AsParallel().ToList();
                for (int i = 0; i < nodeList.Count; i++)
                {
                    var node = nodeList[i];
                    var job = new JobInfo();
                    job.TitleName = node.SelectSingleNode(".//a").Attributes["title"].Value.Substring(2);
                    job.InfoUrl = node.SelectSingleNode(".//a").Attributes["href"].Value;
                    job.Company = node.SelectSingleNode(".//a/dl/dt[@class='company']").InnerText;
                    job.Salary = node.SelectSingleNode(".//a/dl/dt[@class='salary']/em").InnerText;
                    job.City = node.SelectSingleNode(".//a/dl/dt[@class='city']/span").InnerText;
                    job.Date = node.SelectSingleNode(".//a/dl/dt[@class='date']/span").InnerText.Substring(5);
                    job.Source = "猎聘网";
                    job.Method = "年薪";
                    _jobList.Add(job);
                }
            }
            catch (Exception ex)
            {
                LogSave.ErrLogSave("错误【解析】:", ex);
            }
        }