示例#1
0
        public static RapideDdl_HeaderPage LoadHeaderPageFromWeb(pb.Web.v1.RequestFromWeb_v2 request)
        {
            // loadDataFromWeb
            XXElement            xeSource = new XXElement(request.GetXmlDocument().Root);
            string               url      = request.Url;
            RapideDdl_HeaderPage data     = new RapideDdl_HeaderPage();

            //data.urlNextPage = zurl.GetUrl(url, xeSource.XPathValue("//div[@class='navigation']//a[text()='Next']/@href"));
            data.urlNextPage = zurl.GetUrl(url, xeSource.XPathValue("//div[@class='basenavi']//span[@class='nnext']//a/@href"));
            IEnumerable <XXElement>     xeHeaders = xeSource.XPathElements("//div[@class='base shortstory']");
            List <RapideDdl_PostHeader> headers   = new List <RapideDdl_PostHeader>();

            foreach (XXElement xeHeader in xeHeaders)
            {
                RapideDdl_PostHeader header = new RapideDdl_PostHeader();
                header.sourceUrl       = url;
                header.loadFromWebDate = DateTime.Now;

                XXElement xe = xeHeader.XPathElement(".//*[@class='shd']//a");
                header.urlDetail = zurl.GetUrl(url, xe.XPathValue("@href"));
                // xe.XPathValue(".//text()", Download.Print.RapideDdl.RapideDdl.TrimFunc1)
                /////////////////////////////////header.title = Download.Print.RapideDdl.RapideDdl.ExtractTextValues(header.infos, xe.XPathValue(".//text()").Trim(DownloadPrint.TrimChars));

                //xe = xeHeader.XPathElement(".//div[@class='shdinf']/div[@class='shdinf']");
                xe = xeHeader.XPathElement(".//div[@class='shdinf']");
                header.postAuthor = xe.XPathValue(".//span[@class='arg']//a//text()");
                // Aujourd'hui, 17:13
                ////////////////////////////////header.creationDate = Download.Print.RapideDdl.RapideDdl.ParseDateTime(xe.XPathValue(".//span[@class='date']//text()"), (DateTime)header.loadFromWebDate);

                //xe = xeHeader.XPathElement(".//span[@id='post-img']//div[starts-with(@id, 'news-id')]");
                xe = xeHeader.XPathElement(".//div[@class='maincont']");
                //header.images = xe.XPathImages(url, TelechargementPlus.ImagesToSkip);
                //header.images = xe.XPathImages(url);
                //header.images = xe.XPathImages(xeImg => new ImageHtml(xeImg, url)).ToList();
                header.images = xe.DescendantNodes(node => XmlDescendant.ImageFilter(node)).Select(xeImg => new pb.old.ImageHtml((XElement)xeImg, url)).ToList();

                //if (request.LoadImage)
                //    Http2.LoadImageFromWeb(header.images);

                //header.SetTextValues(xe.DescendantTextList());
                header.SetTextValues(xe.DescendantTexts());

                xe = xeHeader.XPathElement(".//div[@class='morelink']//span[@class='arg']");
                //header.category = xe.DescendantTextList(".//span[@class='lcol']").Select(RapideDdl.TrimFunc1).Where(s => s != "E-Book / Magazines" && s != "Catégorie:" && s != "").zToStringValues("/");
                //header.category = xe.DescendantTextList(".//a").Select(Download.Print.RapideDdl.RapideDdl.TrimFunc1).Where(s => !s.StartsWith("Commentaires")).zToStringValues("/");
                header.category = xe.XPathElements(".//a").DescendantTexts().Select(Download.Print.RapideDdl.RapideDdl.TrimFunc1).Where(s => !s.StartsWith("Commentaires")).zToStringValues("/");

                headers.Add(header);
            }
            data.postHeaders = headers.ToArray();
            return(data);
        }
示例#2
0
 // bool desactivateDocumentStore = false
 public static RapideDdl_PostDetail LoadDetailItem(RapideDdl_PostHeader header, bool reload = false, bool loadImage = false, bool refreshDocumentStore = false)
 {
     return(RapideDdl_LoadDetail.Load(header.urlDetail, reload: reload, loadImage: loadImage, refreshDocumentStore: refreshDocumentStore));
 }