Exemplo n.º 1
0
        private BookDownloadItem[] ExtractItems(HtmlDocument doc, BookDownloadItem parent)
        {
            var result = new List <BookDownloadItem>();

            var links = doc.SelectNodes("//div[@id='download']/a");

            foreach (var link in links)
            {
                var item = parent.Clone();
                item.DownloadProvider = "bookdl";
                item.DownloadUrl      = link.Attributes["href"].Value;
                var className = link.Attributes["class"].Value;
                if (className.Contains("pdf"))
                {
                    item.Format = "pdf";
                }
                else if (className.Contains("epub"))
                {
                    item.Format = "epub";
                }
                else if (className.Contains("extras"))
                {
                    item.Format = "extras";
                }
                if (item.Format != null)
                {
                    result.Add(item);
                }
            }

            return(result.ToArray());
        }
Exemplo n.º 2
0
        private BookDownloadItem[] ExtractBooks(HtmlDocument doc, BookDownloadItem parent)
        {
            var result = new List <BookDownloadItem>();

            foreach (var node in doc.SelectNodes("//div[@id='books']/div[@class='bookitem']"))
            {
                var item = new BookDownloadItem();
                item.BookSite = "bookdl";

                var a = node.SelectSingleNode("a");
                if (a == null)
                {
                    continue;
                }
                item.PageUrl = a.Attributes["href"].Value;
                item.Title   = a.Attributes["title"].Value;

                var img = a.SelectSingleNode("img[@class='bookcover']");
                if (img == null)
                {
                    continue;
                }
                item.ImageUrl = img.Attributes["src"].Value;
                if (item.ImageUrl.StartsWith("//"))
                {
                    item.ImageUrl = "http:" + item.ImageUrl;
                }

                result.Add(item);
            }

            return(result.ToArray());
        }
Exemplo n.º 3
0
        private BookDownloadItem[] ExtractItems(HtmlDocument doc, BookDownloadItem parent)
        {
            var result = new List <BookDownloadItem>();

            var trs = doc.SelectNodes("//div[@id='download']/div[@class='panel-body']/table/tbody/tr");

            foreach (var tr in trs)
            {
                var item = parent.Clone();

                item.DownloadProvider = tr.SelectSingleNode("td[1]").InnerText;
                item.DownloadUrl      = tr.SelectSingleNode("td[2]/a").Attributes["href"].Value;
                item.Format           = tr.SelectSingleNode("td[3]").InnerText;

                result.Add(item);
            }

            return(result.ToArray());
        }
Exemplo n.º 4
0
        private BookDownloadItem[] ExtractBooks(HtmlDocument doc, BookDownloadItem parent)
        {
            var result = new List <BookDownloadItem>();

            foreach (var node in doc.SelectNodes("//div[@class='col-sm-6 col-md-3 col-lg-2']/div[@class='thumbnail']"))
            {
                var item = new BookDownloadItem();
                item.BookSite = "foxebook";

                var title = node.SelectSingleNode("span[@class='book-title']");
                if (title == null)
                {
                    continue;
                }
                item.Title = title.InnerText;

                var a = node.SelectSingleNode("a[@rel='bookmark']");
                if (a == null)
                {
                    continue;
                }
                item.PageUrl = HtmlHelper.CombineUrl(SiteUrl, a.Attributes["href"].Value);

                var img = a.SelectSingleNode("img[@class='cover']");
                if (img == null)
                {
                    continue;
                }
                item.ImageUrl = img.Attributes["src"].Value;
                if (item.ImageUrl.StartsWith("//"))
                {
                    item.ImageUrl = "http:" + item.ImageUrl;
                }

                result.Add(item);
            }

            return(result.ToArray());
        }
Exemplo n.º 5
0
 public static T Extract <T>(this HtmlDocument doc, BookDownloadItem parent, Func <HtmlDocument, BookDownloadItem, T> handler)
 {
     return(handler(doc, parent));
 }