Пример #1
0
        public IEnumerable <Ebookdz_Forum> LoadSubForum(string url, string forum, Predicate <string> filter = null, bool reload = false)
        {
            LoadDataFromWeb_v4 loadDataFromWeb = Load(new RequestFromWeb_v4(new HttpRequest {
                Url = url
            }, reload: reload));

            if (loadDataFromWeb.LoadResult)
            {
                XXElement xeSource = new XXElement(loadDataFromWeb.Http.zGetXDocument().Root);

                // <div class="body_bd">
                // <div id="forumbits" class="forumbits">
                // <ol>
                // <li id="forum10" class="forumbit_post new L1">
                //   <div class="forumrow">
                //   <ol id="childforum_for_161" class="childsubforum">
                //     <div class="titleline">
                foreach (XXElement xe in xeSource.XPathElements("//div[@id='forumbits']/ol/li"))
                {
                    XXElement xe2      = xe.XPathElement(".//div[@class='forumrow']//a");
                    string    category = xe2.XPathValue(".//text()");
                    url = Ebookdz.GetUrl(zurl.GetUrl(loadDataFromWeb.WebRequest.HttpRequest.Url, xe2.XPathValue("@href")));
                    yield return(new Ebookdz_Forum {
                        Forum = forum, Category = category, Url = url
                    });

                    foreach (XXElement xe3 in xe.XPathElements(".//ol[@class='childsubforum']/li//div[@class='titleline']//a"))
                    {
                        string name = xe3.XPathValue(".//text()");

                        if (filter != null && !filter(name))
                        {
                            continue;
                        }
                        url = Ebookdz.GetUrl(zurl.GetUrl(loadDataFromWeb.WebRequest.HttpRequest.Url, xe3.XPathValue("@href")));
                        yield return(new Ebookdz_Forum {
                            Forum = forum, Category = category, Name = name, Url = url
                        });
                    }
                }
            }
        }
Пример #2
0
        public IEnumerable <Ebookdz_Forum> LoadMainForum(Predicate <string> filter = null, bool reload = false)
        {
            LoadDataFromWeb_v4 loadDataFromWeb = Load(new RequestFromWeb_v4(new HttpRequest {
                Url = __urlForum
            }, reload: reload));

            if (loadDataFromWeb.LoadResult)
            {
                XXElement xeSource = new XXElement(loadDataFromWeb.Http.zGetXDocument().Root);
                //HtmlRun.Select("//ol[@id='forums']/li:.:EmptyRow", ".//text()", ".//a//text()", ".//a/@href");
                // <ol id="forums" class="floatcontainer">
                foreach (XXElement xe in xeSource.XPathElements("//ol[@id='forums']/li"))
                {
                    // Accueil de la Board, Forum de l'entraide, Journaux, MAGAZINES, Les Livres, Sujet supprimés ou à supprimer
                    // http://www.ebookdz.com/forum/forumdisplay.php?f=1&s=1fdf76d35a57d09aa11e75ff6f0d9985
                    XXElement xe2 = xe.XPathElement(".//a");

                    string name = xe2.XPathValue(".//text()");

                    if (filter != null && !filter(name))
                    {
                        continue;
                    }

                    string url = Ebookdz.GetUrl(zurl.GetUrl(loadDataFromWeb.WebRequest.HttpRequest.Url, xe2.XPathValue("@href")));
                    //if (url != null)
                    //{
                    //    PBUriBuilder uriBuilder = new PBUriBuilder(url);
                    //    uriBuilder.RemoveQueryValue("s");
                    //    url = uriBuilder.ToString();
                    //}
                    yield return(new Ebookdz_Forum {
                        Forum = name, Url = url
                    });
                }
            }
        }