Beispiel #1
0
 public void InsertTest()
 {
     Job param = new Job(); // TODO: 初始化为适当的值
     param.title = "test";
     param.poster_email = "*****@*****.**";
     JobMap.Insert(param);
     Assert.Inconclusive("无法验证不返回值的方法。");
 }
Beispiel #2
0
        public Job GetJobInfoParser(string url)
        {
            Job jobinfo = new Job();

            string title = string.Empty;
            string description = string.Empty;
            DateTime dt = DateTime.Now;
            string email = string.Empty;

            Parser parser = new Parser(new HttpProtocol(new Uri(url)));

            NodeFilter detail = new HasAttributeFilter("class", "d_left");

            NodeList nodeDetail = parser.ExtractAllNodesThatMatch(detail);
            if (nodeDetail == null || nodeDetail.Count == 0)
            {
                return jobinfo;
            }

            description = GetDetailString(nodeDetail);
            Match m = Regex.Match(description, @"发布时间:(?<date>\d\d\d\d-\d{1,2}\-\d{1,2} \d{1,2}\:\d{1,2})");

            dt = DateTime.Now;

            if (m.Success && m.Groups["date"].Success && DateTime.TryParse(m.Groups["date"].Value, out dt)) { }

            Match emailMatch = Regex.Match(description, @"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)");
            if (emailMatch.Success)
            {
                email = emailMatch.Value;
            }

            Match telMatch = Regex.Match(description, @"(1[3|5|8][0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}");
            if (telMatch.Success)
            {
                jobinfo.tel = telMatch.Value;
            }

            jobinfo.category_id = Catalog.id;
            jobinfo.title = title;
            jobinfo.description = description;
            jobinfo.created_on = dt;
            jobinfo.is_active = true;
            jobinfo.city_id = Catalog.city.id;
            jobinfo.sp1010url = url;
            jobinfo.poster_email = email;

            return jobinfo;
        }
Beispiel #3
0
        public void GetContartInfo(NodeList list, ref Job info)
        {
            string miaoshu = list[0].ToString();
            if (string.IsNullOrEmpty(miaoshu))
            {
                return;
            }

            miaoshu = Regex.Replace(miaoshu,@"(\\t|\s)","");

            Match company = Regex.Match(miaoshu, @"Txt\(4903\[108\,12\]\,4935\[110\,16\]\)\:\\n(?<company>\w*)\\n...End", RegexOptions.Multiline);
            if (company.Success)
            {
                info.company = company.Value;
            }
        }
Beispiel #4
0
        public Job GetDetail(string url)
        {
            Job info = new Job();

            Parser parser = ParserHelp.GetParser(url);

            NodeFilter miaoShu = new HasAttributeFilter("id", "miaoshu");
            NodeFilter mainBox = new HasAttributeFilter("class", "mainBox");
            NodeFilter orfilter = new OrFilter(miaoShu, mainBox);

            NodeList list = new NodeList();
            list = parser.Parse(orfilter);
            if (list == null || list.Count < 2)
            {
                return info;
            }

            GetMiaoShu(list, ref info);
            GetContartInfo(list, ref info);

            return info;
        }
Beispiel #5
0
 public void GetMiaoShu(NodeList list, ref Job info)
 {
     string miaoshu = list[1].ToPlainTextString();
     miaoshu = Regex.Replace(miaoshu, @"^[\s|\t]{1,}", "", RegexOptions.Multiline);
     info.description = miaoshu;
 }
Beispiel #6
0
 public static void Insert(Job param)
 {
     MapperHelper.Instance().Insert("JobMap.InsertJob", param);
 }
Beispiel #7
0
        private void InsertJobInfo(Job jobinfo)
        {
            if (string.IsNullOrEmpty(jobinfo.title) || string.IsNullOrEmpty(jobinfo.description))
            {
                return;
            }

            bool sign = true;
            while (sign)
            {
                try
                {
                    JobMap.Insert(jobinfo);

                    sign = false;
                }
                catch (Exception ex)
                {
                    SpiderEventLog.WriteWarningLog("HtmlParse InsertJobInfo error:" + ex.ToString());

                    Thread.Sleep(3000);
                    sign=true;
                }
            }
        }