Example #1
0
        public static void Test_frboard_03()
        {
            //string url = "http://www.frboard.com/magazines-et-journaux/441873-multi-les-journaux-mardi-13-aout-2013-pdf-lien-direct.html";
            //string url = "http://www.frboard.com/magazines-et-journaux/442257-multi-les-journaux-mercredi-14-aout-2013-pdf-lien-direct.html";
            //string url = "http://www.frboard.com/magazines-et-journaux/442270-multi-le-monde-du-jeudi-15-aout-2013-pdf.html";
            string url = "http://www.frboard.com/magazines-et-journaux/442649-multi-les-magazines-jeudi-15-aout-2013-pdf-liens-direct-new-post.html";
            //string url = "";
            //string url = "";
            //string url = "";
            //string url = "";
            //HtmlXmlReader.CurrentHtmlXmlReader.Cookies.zAdd("http://www.frboard.com/", Frboard.GetCookies());
            HttpRequestParameters_v1 requestParameters = new HttpRequestParameters_v1();

            requestParameters.cookies.zAdd("http://www.frboard.com/", Frboard.GetCookies());
            pb.old.HtmlXmlReader.CurrentHtmlXmlReader.Load(url, requestParameters);

            string    xpath = "//div[@class='postbody']//div[@class='postrow has_after_content']";
            XDocument doc   = pb.old.HtmlXmlReader.CurrentHtmlXmlReader.XDocument;
            XElement  xe    = doc.Root.zXPathElement(xpath);

            if (xe == null)
            {
                Trace.WriteLine("node not found \"{0}\"", xpath);
                return;
            }

            xpath = ".//div[@class='content']";
            xe    = xe.XPathSelectElement(xpath);
            if (xe == null)
            {
                Trace.WriteLine("node not found \"{0}\"", xpath);
                return;
            }

            //foreach (XXNode child in xe.DescendantNodes().zWhereSelect(FrboardPost.Filter))
            foreach (pb.old.XXNode child in FrboardPostFilter.GetFilteredNodeList(xe))
            {
                Trace.WriteLine(child.ToString());
            }
        }
Example #2
0
        //public static void Test_frboard_01()
        //{
        //    string url = "http://www.frboard.com/magazines-et-journaux/";
        //    HtmlXmlReader.CurrentHtmlXmlReader.Load(url);
        //    HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//li[starts-with(@class, 'threadbit')]",
        //        ".//h3[@class='threadtitle']//a/@href:.:n(href)",
        //        ".//h3[@class='threadtitle']//a/text():.:n(label1)",
        //        ".//div[@class='author']//text():.:Concat( ):n(author)");
        //    //HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//span[@class='prev_next']//a[@rel='next']/@href");
        //}

        public static void Test_frboard_02()
        {
            //string url = "http://www.frboard.com/magazines-et-journaux/441873-multi-les-journaux-mardi-13-aout-2013-pdf-lien-direct.html";
            //string url = "http://www.frboard.com/magazines-et-journaux/442257-multi-les-journaux-mercredi-14-aout-2013-pdf-lien-direct.html";
            //string url = "http://www.frboard.com/magazines-et-journaux/442270-multi-le-monde-du-jeudi-15-aout-2013-pdf.html";
            string url = "http://www.frboard.com/magazines-et-journaux/442649-multi-les-magazines-jeudi-15-aout-2013-pdf-liens-direct-new-post.html";
            //string url = "";
            //string url = "";
            //string url = "";
            //string url = "";
            //HtmlXmlReader.CurrentHtmlXmlReader.Cookies.zAdd("http://www.frboard.com/", Frboard.GetCookies());
            HttpRequestParameters_v1 requestParameters = new HttpRequestParameters_v1();

            requestParameters.cookies.zAdd("http://www.frboard.com/", Frboard.GetCookies());
            pb.old.HtmlXmlReader.CurrentHtmlXmlReader.Load(url, requestParameters);


            // <div class="postbody"> <div class="content"> <blockquote class="postcontent restore ">
            // <div class="postbody"> <div class="postrow has_after_content">
            //HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//div[@class='postbody']//blockquote");
            //string xpath = "//div[@class='postbody']//blockquote";
            //string xpath = "//div[@class='postbody']//div[@class='postrow has_after_content']";
            string    xpath = "//div[@class='postbody']//div[@class='postrow has_after_content']";
            XDocument doc   = pb.old.HtmlXmlReader.CurrentHtmlXmlReader.XDocument;
            XElement  xe    = doc.Root.zXPathElement(xpath);

            if (xe == null)
            {
                Trace.WriteLine("node not found \"{0}\"", xpath);
                return;
            }
            Trace.WriteLine("found \"{0}\"", xpath);
            Trace.WriteLine("date \"{0}\" time \"{1}\"", doc.Root.zXPathValue("//span[@class='date']//text()"), doc.Root.zXPathValue("//span[@class='time']//text()"));

            // <div class="userinfo">  <div class="username_container"> <div class="popupmenu memberaction">
            // <a rel="nofollow" class="username offline popupctrl" href="http://www.frboard.com/members/145457-lc.good.day.html" title="LC.GooD.Day est déconnecté"><strong>
            // <img src="http://www.frboard.com/images/misc/ur/general.png" class="userrank"></img><strong><font color="#696969">LC.GooD.Day</font></strong></strong></a>
            Trace.WriteLine("author \"{0}\"", doc.Root.zXPathValue("//div[@class='userinfo']//a//text()"));

            xpath = ".//div[@class='content']";
            xe    = xe.XPathSelectElement(xpath);
            if (xe == null)
            {
                Trace.WriteLine("node not found \"{0}\"", xpath);
                return;
            }

            foreach (XNode child in xe.DescendantNodes())
            {
                if (child is XElement)
                {
                    XElement xeChild = child as XElement;
                    //Trace.WriteLine("child element \"{0}\"", xeChild.Name);
                    if (xeChild.Name == "img")
                    {
                        Trace.WriteLine("img src \"{0}\" alt \"{1}\" title \"{2}\" class \"{3}\"",
                                        xeChild.zAttribValue("src"), xeChild.zAttribValue("alt"), xeChild.zAttribValue("title"), xeChild.zAttribValue("class"));
                    }
                }
                else if (child is XText)
                {
                    XText xtextChild = child as XText;
                    if (child.Parent.Name == "a")
                    {
                        Trace.WriteLine("link \"{0}\" href \"{1}\" rel \"{2}\"", xtextChild.Value, child.Parent.zAttribValue("href"), child.Parent.zAttribValue("rel"));
                    }
                    else
                    {
                        Trace.WriteLine("text \"{0}\"", xtextChild.Value.Trim());
                    }
                }
                else
                {
                    Trace.WriteLine("child \"{0}\"", child.NodeType);
                }
            }
            Trace.WriteLine();


            //HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//li[starts-with(@class, 'threadbit')]",
            //    ".//h3[@class='threadtitle']//a/@href:.:n(href)",
            //    ".//h3[@class='threadtitle']//a/text():.:n(label1)",
            //    ".//div[@class='author']//text():.:Concat( ):n(author)");
            //HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//span[@class='prev_next']//a[@rel='next']/@href");
        }