Пример #1
0
        static void TestT()
        {
            var source = WebTool.GetHtmlAsyncUtf8("http://www.mobile01.com/topicdetail.php?f=568&t=3299999");

            string aid    = null;
            string aowner = null;
            string forum  = null;

            TmpUser = new Dictionary <string, string>();

            source = WebTool.GetContent("<div class=\"forum-content\">", "<div class=\"sidebar\">", source);

            //Get Title
            var title = WebTool.GetContent("<h2 class=\"topic\">", "</h2>", source);
            //Get Page
            var page = WebTool.GetContent("<p class=\"numbers\">", "</p>", source);

            //process post -begin-
            source = WebTool.GetContent("<div class=\"single-post\">", "<div class=\"pagination\">", source);
            var ar = source.Split(new[] { "<div class=\"single-post\">" }, StringSplitOptions.RemoveEmptyEntries);

            //Get all
            foreach (var s in ar)
            {
                ProcessPost(s, ref aid, ref aowner, forum, title);
            }
        }
Пример #2
0
        static void TestP()     //get date and replay
        {
            var source = WebTool.GetHtmlAsyncUtf8("http://www.mobile01.com/forumtopic.php?c=16&s=20");

            source = WebTool.GetContent("<table summary=\"文章列表\">", "</table>", source);
            source = WebTool.GetContent("<tbody>", "</tbody>", source).Replace("\n", string.Empty); //topic list
            var arTopic = source.Split(new[] { "<tr>" }, StringSplitOptions.RemoveEmptyEntries);

            arTopic = arTopic.Where(x => x.Trim().Length > 10).ToArray();
            foreach (var s in arTopic)
            {
                var reply      = WebTool.GetContent("<td width=\"7%\" class=\"reply\">", "</td>", s).Replace(",", string.Empty);
                var postDate   = Convert.ToDateTime(WebTool.StripTagsCharArray(WebTool.GetContent("<td width=\"17%\" class=\"authur\">", "</p>", s)));
                var url        = WebTool.GetContent("<td class=\"subject\">", "</a>", s);
                var topicUrl   = WebTool.GetContent("<a href=\"", "\"", url);
                var topicTitle = WebTool.StripTagsCharArray((url.Split(new[] { "</td>" }, StringSplitOptions.RemoveEmptyEntries)[0])).Trim();
                Console.WriteLine("topicUrl=" + topicUrl + "\ntopicTitle=" + HttpUtility.HtmlDecode(topicTitle) +
                                  "\nreply=" + reply + "\ndate=" + postDate);
                if (postDate > Convert.ToDateTime("2013-03-15"))
                {
                    Console.WriteLine("Date over 2013-03-15" + postDate);
                }
            }
        }