コード例 #1
0
ファイル: Program.cs プロジェクト: xxy1991/cozy
        private static void Parse(object param)
        {
            while (true)
            {
                string result = null;
                lock (chacheLocker)
                {
                    if(WebCache.Count > 0)
                    {
                        result = WebCache.Dequeue();
                    }
                }
                if (result != null)
                {
                    try
                    {
                        var Info = new StarInfo();
                        var content = reader.Read(result);
                        var boxpos = content.IndexOf("<div class=\"avatar-box\">");
                        if (boxpos != -1)
                        {
                            var photopos = content.IndexOf("<div class=\"photo-frame\">", boxpos);
                            if (photopos != -1)
                            {
                                var photo = MatchText(@"http://", "\"", content, photopos);
                                if(photo != null)
                                {
                                   Info.Photo = photo;
                                }
                            }
                            var infopos = content.IndexOf("<div class=\"photo-info\">", photopos);
                            if (infopos != -1)
                            {
                                var name = MatchText("<span class=\"pb10\">", @"</span>", content, infopos);
                                if(name != null)
                                {
                                    Info.Name = name;

                                }
                                var birthday = MatchText("<p>生日:", @"</p>", content, infopos);
                                if(birthday != null)
                                {
                                    Info.Birthday = birthday;
                                }

                                var age = MatchText("<p>年龄:", @"</p>", content, infopos);
                                if (age != null)
                                {
                                    Info.Age = age;
                                }

                                var cup = MatchText("<p>罩杯:", @"</p>", content, infopos);
                                if (cup != null)
                                {
                                    Info.Cup = cup;
                                }

                                var chest = MatchText("<p>胸围:", @"</p>", content, infopos);
                                if (chest != null)
                                {
                                    Info.Chest = chest;
                                }

                                var waist = MatchText("<p>腰围:", @"</p>", content, infopos);
                                if (waist != null)
                                {
                                    Info.Waist = waist;
                                }

                                var hip = MatchText("<p>臀围:", @"</p>", content, infopos);
                                if (hip != null)
                                {
                                    Info.Hip = hip;
                                }
                            }
                        }
                        lock(listLocker)
                        {
                            InfoList.Add(Info);
                        }
                        Console.WriteLine("获取到一个 还剩{0}个", WebCache.Count);
                    }
                    catch(Exception)
                    {

                    }
                }
                else
                {
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sgww/cozy
        private static void Parse(object param)
        {
            while (true)
            {
                string result = null;
                lock (chacheLocker)
                {
                    if (WebCache.Count > 0)
                    {
                        result = WebCache.Dequeue();
                    }
                }
                if (result != null)
                {
                    try
                    {
                        var Info    = new StarInfo();
                        var content = reader.Read(result);
                        var boxpos  = content.IndexOf("<div class=\"avatar-box\">");
                        if (boxpos != -1)
                        {
                            var photopos = content.IndexOf("<div class=\"photo-frame\">", boxpos);
                            if (photopos != -1)
                            {
                                var photo = MatchText(@"http://", "\"", content, photopos);
                                if (photo != null)
                                {
                                    Info.Photo = photo;
                                }
                            }
                            var infopos = content.IndexOf("<div class=\"photo-info\">", photopos);
                            if (infopos != -1)
                            {
                                var name = MatchText("<span class=\"pb10\">", @"</span>", content, infopos);
                                if (name != null)
                                {
                                    Info.Name = name;
                                }
                                var birthday = MatchText("<p>生日:", @"</p>", content, infopos);
                                if (birthday != null)
                                {
                                    Info.Birthday = birthday;
                                }

                                var age = MatchText("<p>年龄:", @"</p>", content, infopos);
                                if (age != null)
                                {
                                    Info.Age = age;
                                }

                                var cup = MatchText("<p>罩杯:", @"</p>", content, infopos);
                                if (cup != null)
                                {
                                    Info.Cup = cup;
                                }

                                var chest = MatchText("<p>胸围:", @"</p>", content, infopos);
                                if (chest != null)
                                {
                                    Info.Chest = chest;
                                }

                                var waist = MatchText("<p>腰围:", @"</p>", content, infopos);
                                if (waist != null)
                                {
                                    Info.Waist = waist;
                                }

                                var hip = MatchText("<p>臀围:", @"</p>", content, infopos);
                                if (hip != null)
                                {
                                    Info.Hip = hip;
                                }
                            }
                        }
                        lock (listLocker)
                        {
                            InfoList.Add(Info);
                        }
                        Console.WriteLine("获取到一个 还剩{0}个", WebCache.Count);
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    break;
                }
            }
        }