黑马程序员技术交流社区

标题: 提取招聘网站职位信息 [打印本页]

作者: 郝滨    时间: 2013-2-25 20:21
标题: 提取招聘网站职位信息
   string url = "http://sou.zhaopin.com/jobs/searchresult.ashx?bj=160000&jl=530&sm=0&p=1";
            WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            string html = wc.DownloadString(url);
            //<td class="Jobname"><input type="checkbox"  name="vacancyid" value="CC132250291J90251006000_530" /><a href="http://jobs.zhaopin.com/beijing/y08hadoophbase%e5%ad%98%e5%82%a8%e5%b9%b3%e5%8f%b0%e5%8c%96%e7%b3%bb_132250291251006.htm" target="_blank">Y08-hadoop/hbase存储平台化系统研发工程师(云平台)</a></td>

//<td class="Jobname"><input type="checkbox"  name="vacancyid" value="CC487620826J90250013000_530" /><a  target="_blank">文档工程师  网站编辑</a></td>
            string str = "<td class="Jobname">\.+\>(\.)</a></td>";//额 ,明显的不行呀
            MatchCollection matches = Regex.Matches(html, str);
            foreach (Match  mat in matches)
            {
                if (mat.Success)
                {
                    
                }
            }
            Console.ReadKey();
就是红色字体显示的那样,要如何用正则表达式选出其中“文档工程师  网站编辑” 这样的职位信息?

作者: 王立    时间: 2013-2-25 20:37
string url = "http://sou.zhaopin.com/jobs/searchresult.ashx?bj=160000&jl=530&sm=0&p=1";
            WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            string html = wc.DownloadString(url);

            MatchCollection matches = Regex.Matches(html, "target=\"_blank\">(?<value>.+?)</a></td>");
            foreach (Match mat in matches)
            {
                if (mat.Success)
                {
                    string value = mat.Groups["value"].Value.ToString();
                    MessageBox.Show(value);
                }
            }
作者: 郝滨    时间: 2013-2-26 08:17
王立 发表于 2013-2-25 20:37
string url = "http://sou.zhaopin.com/jobs/searchresult.ashx?bj=160000&jl=530&sm=0&p=1";
            ...

嗯 可以了 就是前几条后面出现三行代码  剩下的都正常输出  还把公司名称输出了




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2