예제 #1
0
파일: frboard1.cs 프로젝트: 24/source_04
 private bool GetNextPrintFromWeb()
 {
     _currentPrint = null;
     if (_enumNodes == null)
     {
         return(false);
     }
     while (_enumNodes.MoveNext())
     {
         XXNode node = _enumNodes.Current;
         if (node.type == XXNodeType.Text)
         {
             AddTextNode(node as XXNodeText);
         }
         else if (node.type == XXNodeType.Image)
         {
             XXNodeImage img = node as XXNodeImage;
             if (_postMultiPrint && !img.followingImage)
             {
                 if (_workingPrint.title != null && _workingPrint.images.Count > 0)
                 {
                     //_prints.Add(_print);
                     _currentPrint = _workingPrint;
                 }
                 NewPrint();
             }
             ImageHtml imgUrl = new ImageHtml(img.source, img.alt, img.title, img.className);
             if (_loadImage)
             {
                 imgUrl.Image = Frboard.LoadImageFromWeb(imgUrl.Source);
             }
             _workingPrint.images.Add(imgUrl);
             if (_currentPrint != null)
             {
                 return(true);
             }
         }
         else if (node.type == XXNodeType.Link)
         {
             AddTextNode(null);
             XXNodeLink link = node as XXNodeLink;
             _workingPrint.downloadLinks.Add(link.text);
         }
     }
     _enumNodes = null;
     AddTextNode(null);
     if (_workingPrint.title != null && _workingPrint.images.Count > 0)
     {
         //_prints.Add(_print);
         _currentPrint = _workingPrint;
         return(true);
     }
     return(false);
 }
예제 #2
0
파일: frboard1.cs 프로젝트: 24/source_04
 public void LoadFromWeb()
 {
     if (_enumNodes != null)
     {
         return;
     }
     if (Frboard.LoadUrl(_url))
     {
         _root            = Frboard.HtmlReader.XDocument.Root;
         _loadFromWebDate = DateTime.Now;
         InitPost();
         _loadFromWeb = true;
     }
 }
예제 #3
0
파일: frboard_f.cs 프로젝트: 24/source_04
        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());
            }
        }
예제 #4
0
파일: frboard_f.cs 프로젝트: 24/source_04
        //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");
        }