Exemple #1
0
        public List <MemberEntity> SelectAllMember()
        {
            List <MemberEntity> members  = new List <MemberEntity>();
            XmlNode             rootNode = objXmlDoc.SelectSingleNode("jobbole");

            foreach (XmlNode item in rootNode.ChildNodes)
            {
                MemberEntity member = new MemberEntity();
                if (String.IsNullOrEmpty(item.Attributes["Id"].Value.ToString()))
                {
                    member.Id = 0;
                }
                else
                {
                    member.Id = Convert.ToInt32(item.Attributes["Id"].Value.ToString());
                }
                member.name       = item.Attributes["name"].Value.ToString();
                member.image      = item.Attributes["image"].Value.ToString();
                member.medal      = item.Attributes["medal"].Value.ToString();
                member.point      = item.Attributes["point"].Value.ToString();
                member.profile    = item.Attributes["profile"].Value.ToString();
                member.reputation = item.Attributes["reputation"].Value.ToString();
                member.sex        = item.Attributes["sex"].Value.ToString();
                member.url        = item.Attributes["url"].Value.ToString();
                member.city       = item.Attributes["city"].Value.ToString();
                member.Date       = item.Attributes["Date"].Value.ToString();
                member.follower   = item.Attributes["follower"].Value.ToString();
                member.following  = item.Attributes["following"].Value.ToString();
                members.Add(member);
            }
            return(members);
        }
Exemple #2
0
        private void insertXML(MemberEntity member)
        {
            XMLHelper xmlHelper = new XMLHelper("jobbole");

            xmlHelper.CreateXml();
            xmlHelper.Insert(member);
            xmlHelper.Save();
        }
Exemple #3
0
 public bool AddMember(MemberEntity member)
 {
     if (IsMember(member.url))
     {
         return(false);
     }
     else
     {
         Member.Add(member);
         return(true);
     }
 }
Exemple #4
0
        public void Insert(MemberEntity member)
        {
            XmlNode    rootElement = objXmlDoc.SelectSingleNode("jobbole");
            XmlElement node        = objXmlDoc.CreateElement("member");//创建一个<Node>节点

            node.SetAttribute("Id", member.Id.ToString() == null ? "" : member.Id.ToString());
            node.SetAttribute("name", member.name == null ? "" : member.name);
            node.SetAttribute("image", member.image == null ? "" : member.image);
            node.SetAttribute("medal", member.medal == null ? "" : member.medal);
            node.SetAttribute("point", member.point == null ? "" : member.point);
            node.SetAttribute("profile", member.profile == null ? "" : member.profile);
            node.SetAttribute("reputation", member.reputation == null ? "" : member.reputation);
            node.SetAttribute("sex", member.sex == null ? "" : member.sex);
            node.SetAttribute("url", member.url == null ? "" : member.url);
            node.SetAttribute("city", member.city == null ? "" : member.city);
            node.SetAttribute("Date", member.Date == null ? "" : member.Date);
            node.SetAttribute("follower", member.follower == null ? "" : member.follower);
            node.SetAttribute("following", member.following == null ? "" : member.following);
            rootElement.AppendChild(node);
        }
Exemple #5
0
        public void LoadUser(string userUrl)
        {
            MemberEntity member = new MemberEntity();

            member.url = userUrl;
            try
            {
                JumonyHelper jumonyHelper = new JumonyHelper(userUrl);
                var          nameValue    = jumonyHelper.doc.FindFirst(".profile-title");
                string       name         = nameValue.InnerText();
                member.name = name;
                var profiles = jumonyHelper.doc.Find(".profile-points > li");
                foreach (var item in profiles)
                {
                    string value = item.InnerText();
                    if (value.Contains("\r\n"))
                    {
                        value = value.Replace("\r\n", "|");
                        string[] pros = value.Split('|');
                        if (pros[1] == "声望")
                        {
                            member.reputation = pros[0];
                        }
                        else if (pros[1] == "勋章")
                        {
                            member.medal = pros[0];
                        }
                        else if (pros[1] == "积分")
                        {
                            member.point = pros[0];
                        }
                    }
                }
                var profile = jumonyHelper.doc.FindFirst(".profile-bio");
                member.profile = profile.InnerText();
                var follows = jumonyHelper.doc.Find(".profile-follow");
                foreach (var item in follows)
                {
                    string value = item.InnerText();
                    if (!String.IsNullOrEmpty(value))
                    {
                        if (value.Contains("关注"))
                        {
                            string following = value.Split('(')[1].Split(')')[0];
                            member.following = following;
                        }
                        else if (value.Contains("粉丝"))
                        {
                            string follower = value.Split('(')[1].Split(')')[0];
                            member.follower = follower;
                        }
                    }
                }
                var infos = jumonyHelper.doc.Find(".member-info > span");
                foreach (var item in infos)
                {
                    string value = item.InnerText();
                    if (!String.IsNullOrEmpty(value))
                    {
                        if (value.Contains("注册"))
                        {
                            string date = value.Split(':')[1];
                            member.Date = date;
                        }
                        else if (value.Contains("城市"))
                        {
                            string city = value.Split(':')[1];
                            member.city = city;
                        }
                    }
                }

                var    image    = jumonyHelper.doc.FindFirst(".profile-img > a > img");
                string imageUrl = image.Attribute("src").Value();
                member.image = imageUrl;

                if (jumonyHelper.doc.Exists("i[title]"))
                {
                    var    sexHtml = jumonyHelper.doc.FindFirst("i[title]");
                    string sex     = sexHtml.Attribute("title").Value();
                    member.sex = sex;
                }
                else
                {
                    member.sex = "";
                }
                member.Id = UserIndex;
                lock (ReptileObj)
                {
                    memberHelper.AddMember(member);
                    insertXML(member);
                    UserIndex++;
                }
            }
            catch (Exception ex)
            {
                WriteTxt.WriteNewTxt("ERRORLOG", "++++错误数据+++" + ex.Message);
            }
        }