示例#1
0
        private CommentInfo getCommentNode(string item)
        {
            item = item.Replace("\\r", "").Replace("\\t", "").Replace("\\n", "").Replace("\\", "");
            CommentInfo res = new CommentInfo();
            res.Score = RegGroupsX<int>(item, "<span class=\"star s(?<x>\\d+)\">");
            res.Content = RegGroupsX<string>(item, "<span class=\"redTag\">.*?</span>(?<x>.*?)</span>");

            res.Content = CommentBase.FiterContent(res.Content, 6);
            if (string.IsNullOrEmpty(res.Content))
                return null;
            res.SendTime = RegGroupsX<DateTime>(item, @"(?<x>\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2} \d{1,2}:\d{1,2}:\d{1,2})");
            res.UserName = RegGroupsX<string>(item, "userNick=\"(?<x>.*?)\"");
            if (item.Contains("晒单"))
            {
                var imglist = RegGroupCollection(item, "<li data-tpc=\"SHINE\"><img width=\"46\" height=\"46\" src=\"(?<x>.*?)\">");
                if(imglist!=null)
                {
                    foreach (Match match in imglist)
                    {
                        res.ComSmallImg += match.Groups["x"].Value+";";
                    }
                    res.CommBigImg = res.ComSmallImg.Replace("_40x40", "");
                }

            }

            return res;
        }
示例#2
0
        private CommentInfo getCommentNode(string item)
        {
            CommentInfo comm = new CommentInfo();
            comm.Content = RegGroupsX<string>(item, "<div class=\"reviewText\">(?<x>.*?)</div>");
            comm.Content = CommentBase.FiterContent(comm.Content, 6);
            if (string.IsNullOrEmpty(comm.Content))
                return null;
            comm.UserName = RegGroupsX<string>(item, "<span style = \"font-weight: bold;\">(?<x>.*?)</span>");
            string time = RegGroupsX<string>(item, "<nobr>(?<x>.*?)</nobr>");

            if(!string.IsNullOrEmpty(time))
            {
                time = time.Replace("年", "-").Replace("月", "-").Replace("日", "");
                DateTime sendTime = DateTime.MinValue;
                if (DateTime.TryParse(time, out sendTime))
                    comm.SendTime = sendTime;
            }
            comm.Score = RegGroupsX<int>(item, "swSprite s_star_(?<x>\\d+)_\\d+");
            return comm;
        }
示例#3
0
        private CommentInfo getCommentNode(JToken item)
        {
            try
            {

                string content = CommentBase.FiterContent(item["content"].ToString(), 10);
                if (string.IsNullOrEmpty(content))
                    return null;
                string createTime = item["creationTime"].ToString();
                DateTime ctime;
                DateTime.TryParse(createTime, out ctime);
                StringBuilder imags = new StringBuilder();
                StringBuilder BigImags = new StringBuilder();
                if (item["images"] != null)
                {
                    JArray images = (JArray) item["images"];
                    for (int j = 0; j < images.Count(); j++)
                    {
                        imags.Append(images[j]["imgUrl"]);
                        imags.Append(";");
                    }
                }
                int score;
                int.TryParse(item["score"].ToString(), out score);
                if (item["showOrderComment"] != null && item["showOrderComment"]["content"] != null)
                {
                    string ordercom = item["showOrderComment"]["content"].ToString();
                    var imglist = RegGroupCollection(ordercom, "src=\"(?<x>.*?)\"|src='(?<x>.*?)'");
                    if (imglist != null && imglist.Count > 0)
                    {
                        for (int i = 0; i < imglist.Count; i++)
                        {
                            BigImags.Append(imglist[i].Groups["x"].Value);
                            BigImags.Append(";");
                        }
                    }

                }
                CommentInfo info = new CommentInfo
                {
                    UserName = item["nickname"].ToString(),
                    ComSmallImg = imags.ToString(),
                    CommBigImg = BigImags.ToString(),
                    SendTime = ctime,
                    Score = score,
                    Content = content
                };

                return info;
            }
            catch (Exception ex)
            {
                LogServer.WriteLog(ex, "CommentSpiderError");
                return null;
            }
        }