Informations[] GetInformations.GetInformationsFromFile(string FilePath)
        {
            StreamReader reader = new StreamReader(FilePath, Encoding.UTF8);

            Informations[] infos = null;
            string         s     = reader.ReadLine();

            if (s != null)
            {
                int count = int.Parse(s);
                infos = new Informations[count];
                string          text    = reader.ReadToEnd();
                Regex           r       = new Regex("<Informations>(?<informations>.*?)</Informations>");
                MatchCollection matches = r.Matches(text);
                for (int i = 0; i < count; i++)
                {
                    string info = matches[i].Groups["informations"].Value;
                    infos[i] = new Informations();
                    Regex regex = new Regex("<CompanyName>(?<companyname>.*?)</CompanyName>");
                    Match match = regex.Match(info);
                    infos[i].CompanyName = match.Groups["companyname"].Value;
                    regex                   = new Regex("<JobName>(?<jobname>.*?)</JobName>");
                    match                   = regex.Match(info);
                    infos[i].JobName        = match.Groups["jobname"].Value;
                    regex                   = new Regex("<JobDuty>(?<jobduty>.*?)</JobDuty>");
                    match                   = regex.Match(info);
                    infos[i].JobDuty        = match.Groups["jobduty"].Value;
                    regex                   = new Regex("<JobRequire>(?<jobrequire>.*?)</JobRequire>");
                    match                   = regex.Match(info);
                    infos[i].JobRequire     = match.Groups["jobrequire"].Value;
                    regex                   = new Regex("<CompanyType>(?<companytype>.*?)</CompanyType>");
                    match                   = regex.Match(info);
                    infos[i].CompanyType    = match.Groups["companytype"].Value;
                    regex                   = new Regex("<CompanyPrice>(?<companyprice>.*?)</CompanyPrice>");
                    match                   = regex.Match(info);
                    infos[i].CompanyPrice   = match.Groups["companyprice"].Value;
                    regex                   = new Regex("<CompanyAddress>(?<companyaddress>.*?)</CompanyAddress>");
                    match                   = regex.Match(info);
                    infos[i].CompanyAddress = match.Groups["companyaddress"].Value;
                    regex                   = new Regex("<CompanyDetails>(?<companydetails>.*?)</CompanyDetails>");
                    match                   = regex.Match(info);
                    infos[i].CompanyDetails = match.Groups["companydetails"].Value;
                    regex                   = new Regex("<CompanyWebsite>(?<companywebsite>.*?)</CompanyWebsite>");
                    match                   = regex.Match(info);
                    infos[i].CompanyWebsite = match.Groups["companywebsite"].Value;
                }
            }
            reader.Close();
            return(infos);
        }
예제 #2
0
 public Form2(Informations informations)
 {
     this.informations = informations;
     InitializeComponent();
     pictureBox1.BackgroundImage = pictures.Get_PieGraph(informations);
     textBox1.AppendText("公司名称:" + informations.CompanyName + "\n");
     textBox1.AppendText("岗位名称:" + informations.JobName + "\n");
     textBox1.AppendText(informations.JobDuty + "\n");
     textBox1.AppendText(informations.JobRequire + "\n");
     textBox1.AppendText("公司类型:" + informations.CompanyType + "\n");
     textBox1.AppendText("公司荣誉:" + informations.CompanyPrice + "\n");
     textBox1.AppendText("公司地址:" + informations.CompanyAddress + "\n");
     textBox1.AppendText(informations.CompanyDetails + "\n");
     textBox1.AppendText(informations.CompanyWebsite + "\n");
 }
예제 #3
0
        Image Pictures.Get_PieGraph(Informations informations)
        {
            Bitmap   image = new Bitmap(400, 300);
            Graphics g     = Graphics.FromImage(image);

            g.Clear(Color.White);
            double angle      = 0;
            double totalangle = 0;
            Random rand       = new Random();

            foreach (WordWeightPair wordweight in informations.KeyWords)
            {
                int randomNumber = rand.Next(brushes.Length);
                angle = wordweight.Weight * 360;
                g.FillPie(brushes[randomNumber], 220, 150, 120, 120, (int)totalangle, (int)angle);
                g.DrawPie(Pens.Black, 220, 150, 120, 120, (int)totalangle, (int)angle);
                totalangle += angle;
            }
            return(image);
        }
        Informations[] GetInformations.GetInformationsFromHtml(string[] Htmls)
        {
            int i = 0;

            Informations[] infos = new Informations[Htmls.Length];
            while (i < Htmls.Length)
            {
                infos[i] = new Informations();
                WebClient wc = new WebClient();
                wc.Encoding = Encoding.UTF8;
                string html = wc.DownloadString(Htmls[i]);
                html = html.Replace("\n", "");
                Regex           regex   = new Regex("<h2>(?<id>.*?)</h2>");//岗位名称
                MatchCollection matches = regex.Matches(html);
                if (matches.Count > 0)
                {
                    infos[i].JobName = matches[0].Groups["id"].Value.ToString();
                }
                else
                {
                    infos[i].JobName = "NULL";
                }
                regex   = new Regex("<dl class=\"job-duty\">(?<content>.*?)</dl>");               //获取岗位职责内包含的全部字符
                matches = regex.Matches(html);
                Regex           content       = new Regex("<span style=.*?>(?<text>.*?)</span>"); //按行获取岗位职责信息
                MatchCollection matchContents = content.Matches(matches[0].Groups["content"].Value);
                infos[i].JobDuty = "岗位职责:";
                foreach (Match item in matchContents)
                {
                    infos[i].JobDuty += item.Groups["text"].Value.ToString();
                }
                regex               = new Regex("<dl>(?<content>.*?)</dl>"); //获取岗位要求当中包含的全部字符
                content             = new Regex(">(?<text>.*?)<");
                matches             = regex.Matches(html);                   //按行获取岗位要求信息
                matchContents       = content.Matches(matches[0].Groups["content"].Value);
                infos[i].JobRequire = "";
                foreach (Match item in matchContents)
                {
                    infos[i].JobRequire += item.Groups["text"].Value.ToString();
                }
                regex   = new Regex("<p class=\"com-lbs\">(?<address>.*?)</p>");
                matches = regex.Matches(html);
                if (matches.Count > 0)
                {
                    infos[i].CompanyAddress = matches[0].Groups["address"].Value.ToString();
                }
                else
                {
                    infos[i].CompanyAddress = "NULL";
                }
                regex   = new Regex("<a href=\"/recommand\">内推首页</a><span>&gt;</span>(?<companyname>.*?)</div>");
                matches = regex.Matches(html);
                if (matches.Count > 0)
                {
                    infos[i].CompanyName = matches[0].Groups["companyname"].Value.ToString();
                }
                else
                {
                    infos[i].CompanyName = "NULL";
                }
                regex   = new Regex("<div class=\"com-detail\"><p>(?<detail>.*?)</p><p><a href=\"(?<website>.*?)\" target=\"_blank\">(?<web>.*?)</a></p></div>");
                matches = regex.Matches(html);
                content = new Regex(">(?<detail>.*?)<");
                if (matches.Count > 0)
                {
                    matchContents           = content.Matches(matches[0].Groups["detail"].Value.ToString());
                    infos[i].CompanyDetails = "公司详情:";
                    foreach (Match item in matchContents)
                    {
                        infos[i].CompanyDetails += item.Groups["detail"].Value.ToString();
                    }
                    infos[i].CompanyWebsite = "公司网站:" + matches[0].Groups["web"].Value.ToString();
                }
                else
                {
                    infos[i].CompanyDetails = "NULL";
                    infos[i].CompanyWebsite = "NULL";
                }
                regex   = new Regex("<p class=\"com-price\">(?<price>.*?)</p>");
                matches = regex.Matches(html);
                if (matches.Count > 0)
                {
                    infos[i].CompanyPrice = matches[0].Groups["price"].Value.ToString();
                }
                else
                {
                    infos[i].CompanyPrice = "NULL";
                }
                regex   = new Regex("<p class=\"com-type\">(?<type>.*?)</p>");
                matches = regex.Matches(html);
                if (matches.Count > 0)
                {
                    infos[i].CompanyType = matches[0].Groups["type"].Value.ToString();
                }
                else
                {
                    infos[i].CompanyType = "NULL";
                }
                Console.WriteLine(i);
                i++;
            }
            return(infos);
        }
예제 #5
0
        TreeView Pictures.Get_WorkAbilityTree(Informations informations)
        {
            TreeView treeview = null;

            return(treeview);
        }