예제 #1
0
        public Form1()
        {
            InitializeComponent();
            Episodes e = new Episodes(561);

            ParseEpisodeInside(e);
        }
예제 #2
0
        //List<postdate> PostDateUser (IEnumerable<IElement> userlist, IEnumerable<IElement> datelist)
        //{
        //    List<postdate> lpd = new List<postdate>();
        //    for (int i = 0; i < userlist.Count(); i++)
        //    {
        //        IElement ieuser = userlist.Last();
        //        if (!IndexOfUser(lpd, ieuser))
        //        {
        //            postdate pd = new postdate();
        //            pd.user = userlist.Find(ieuser.InnerHtml);
        //    }
        //    }
        //}
        public Episodes ParseEpisodeInside(Episodes epis)
        {
            var config = Configuration.Default.WithJavaScript().WithCss().WithCookies();

            var      parser   = new HtmlParser(config);
            string   str      = getResponse(forumname);
            var      document = parser.Parse(str);
            Episodes episode  = new Episodes(epis.TopicID);

            episode.Status      = epis.Status;
            episode.EpisodeName = epis.EpisodeName;

            //episode.Posts = new Post[12];
            var    link = document.All.Where(m => m.LocalName == "span" && m.ClassName.Contains("item2"));
            var    blueListItemsLinq = document.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("main"));
            string s = "";

            foreach (var item in blueListItemsLinq)
            {
                s += item.InnerHtml;
            }
            var posts = parser.Parse(s);
            var list  = posts.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("container"));
            var list2 = posts.All.Where(m => m.LocalName == "a" && m.ClassList.Contains("permalink"));

            s = "";
            foreach (var item in list)
            {
                s += item.InnerHtml;
            }
            posts = parser.Parse(s);
            var list1 = posts.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("post-author"));

            s = "";
            string s2 = "";

            foreach (var item in list1)
            {
                s += item.InnerHtml;
            }
            foreach (var item in list2)
            {
                s2 += item.InnerHtml;
            }
            posts = parser.Parse(s);
            var list3 = posts.All.Where(m => m.LocalName == "li" && m.ClassList.Contains("pa-author"));

            s = "";
            foreach (var item in list3)
            {
                s += item.InnerHtml;
            }
            posts = parser.Parse(s);
            var list4 = posts.All.Where(m => m.LocalName == "a");

            s = "";
            foreach (var item in list4)
            {
                s += item.InnerHtml + " ";
            }
            StreamWriter ws = new StreamWriter("testc.txt");

            ws.WriteLine(s2);
            ws.Close();
            return(episode);
        }
예제 #3
0
        void ParseEpisodeInTopicmorepages(string link, ref List <Episodes> epss)
        //List<Episodes> ParseEpisodeInTopic(string link)
        {
            // List<Episodes>  = new List<Episodes>();
            var config = Configuration.Default.WithJavaScript().WithCss().WithCookies();

            var    parser   = new HtmlParser(config);
            string str      = /*forParse();//*/ getResponse(link);
            var    document = parser.Parse(str);

            var    blueListItemsLinq = document.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("main"));
            string s = "";

            foreach (var item in blueListItemsLinq)
            {
                s += item.InnerHtml;
            }
            var posts = parser.Parse(s);
            var list  = posts.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("container"));

            s = "";
            foreach (var item in list)
            {
                s += item.InnerHtml;
            }
            posts = parser.Parse(s);
            list  = posts.All.Where(m => m.LocalName == "div" && m.ClassList.Contains("tclcon"));
            s     = "";

            foreach (var item in list)
            {
                s += item.InnerHtml;
                var post  = parser.Parse(item.InnerHtml);
                var post1 = post.All.Where(m => m.LocalName == "a");
                foreach (var v in post1)
                {
                    string id = v.OuterHtml.Remove(0, (26 + forumname.Length));
                    if (id.IndexOf("acchide") < 0)
                    {
                        id = id.Remove(id.Length - 6 - v.InnerHtml.Length, id.Length - 6 - v.InnerHtml.Length);
                        string index = "";
                        int    a     = 0;
                        while (Char.IsDigit(id[a]))
                        {
                            index += id[a]; a++;
                        }
                        Episodes ep = new Episodes(int.Parse(index));
                        ep.EpisodeName = v.InnerHtml;
                        ep.Status      = EpisodeStatuses.Active;
                        epss.Add(ep);
                    }
                }
            }
            int    azaza  = 0;
            string asdasa = parseLinks(link);

            if (asdasa.Length > 0)
            {
                ParseEpisodeInTopicmorepages(asdasa, ref epss);
            }
        }