コード例 #1
0
        void ParserSearchPageHtml(string html, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var rows = doc.GetElementbyId("similarfiles").SelectNodes(".//div");

            if (rows != null)
            {
                foreach (var row in rows)
                {
                    var title = row.SelectSingleNode("span/a");
                    var hash  = Regex.Match(title?.GetAttributeValue("href", "") ?? "", @"se/(\w{40})/", RegexOptions.IgnoreCase).GetGroupValue(1);
                    if (string.IsNullOrEmpty(hash))
                    {
                        continue;
                    }

                    var item = CreateResourceInfo(hash.ToUpper(), title.InnerText);

                    item.DownloadSize   = row.SelectSingleNode("span[5]").InnerText.Trim();
                    item.UpdateTimeDesc = row.SelectSingleNode("span[4]").InnerText.Trim();

                    result.Add(item);
                }
            }

            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = doc.DocumentNode.SelectSingleNode("//td[@class='cur']")?.NextSibling != null;
        }
コード例 #2
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var nodes = doc.DocumentNode.SelectNodes("//div[@class='search-item']");

            if (nodes != null)
            {
                foreach (var node in nodes)
                {
                    var item = CreateResourceInfo(
                        Regex.Match(node.SelectSingleNode(".//a[@class='download'][1]").GetAttributeValue("href", ""), @":([A-F\d]{40})").GetGroupValue(1),
                        node.SelectSingleNode(".//h3/a").InnerText
                        );
                    item.DownloadSize   = node.SelectSingleNode(".//div[@class='item-bar']/span[3]/b")?.InnerText;
                    item.UpdateTimeDesc = node.SelectSingleNode(".//div[@class='item-bar']/span[2]/b")?.InnerText;

                    result.Add(item);
                }
            }
            result.HasPrevious = doc.DocumentNode.SelectSingleNode("//div[@class='bottom-pager']/span/preceding-sibling::*") != null;
            result.HasMore     = doc.DocumentNode.SelectSingleNode("//div[@class='bottom-pager']/span/following-sibling::*") != null;

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #3
0
        void ParserSearchPageHtml(string html, ResourceSearchInfo result)
        {
            string rowContent;
            var    charPosition = 0;

            while (!string.IsNullOrEmpty((rowContent = html.SearchStringTag(@"<div class=""row"">", "    </div>", ref charPosition))))
            {
                var hash = Regex.Match(rowContent, @"hash\/([a-f\d]{40})['""]", RegexOptions.IgnoreCase).GetGroupValue(1);
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash.ToUpper();
                item.Provider = this;

                //标题
                item.Title        = Regex.Match(rowContent, @"title=['""](.*?)['""]", RegexOptions.IgnoreCase).GetGroupValue(1).DefaultForEmpty(".....");
                item.DownloadSize = Regex.Match(rowContent, @"size"">([^<]+?)<", RegexOptions.IgnoreCase).GetGroupValue(1);
                item.UpdateTime   = Regex.Match(rowContent, @"date"">([^<]+?)<", RegexOptions.IgnoreCase).GetGroupValue(1).ToDateTimeNullable();

                result.Add(item);
            }

            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = html.IndexOf(">Next <", StringComparison.OrdinalIgnoreCase) != -1;
        }
コード例 #4
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var parser = new JumonyParser();
            var doc    = parser.Parse(htmlContent, new Uri(ReferUrlPage));

            var node = doc.Find("#archiveResult tr").Skip(1);

            foreach (var row in node)
            {
                var title = row.FindFirstOrDefault("td.name")?.InnerText();
                //var size = row.FindFirstOrDefault("td.size")?.InnerText();
                var date = row.FindFirstOrDefault("td.date")?.InnerText()?.ToDateTimeNullable();
                var has  = Regex.Match(row.FindFirstOrDefault("td.action a:nth-child(1)").Attribute("href").AttributeValue, @"/([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);

                var item = CreateResourceInfo(has, title);
                //item.DownloadSize = size;
                item.UpdateTime = date;

                result.Add(item);
            }

            var pager = doc.FindFirstOrDefault("div.pagination");

            result.HasPrevious = pager?.FindFirstOrDefault("*:first-child")?.Name == "a";
            result.HasMore     = pager?.FindFirstOrDefault("*:last-child")?.Name == "a";

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #5
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc  = CreateHtmlDocument(htmlContent);
            var rows = doc.DocumentNode.SelectNodes("//table[@class='tl']/tr");

            if (rows != null)
            {
                foreach (var row in rows)
                {
                    var titlelink = row.SelectSingleNode("td[3]/a");
                    var title     = titlelink.InnerText;
                    var linkinfo  = Regex.Match(titlelink.GetAttributeValue("href", ""), @"torrent/(\d+)/(.*?)\.html", RegexOptions.IgnoreCase);
                    var size      = row.SelectSingleNode("td[4]").InnerText;

                    var res = CreateResourceInfo(null, title);
                    res.SiteData = new SiteInfo()
                    {
                        SiteID   = linkinfo.GetGroupValue(1).ToInt64(),
                        PageName = linkinfo.GetGroupValue(2)
                    };
                    res.DownloadSize = size;

                    result.Add(res);
                }

                var currentPage = doc.DocumentNode.SelectSingleNode("//b[@class='pager_no_link']");
                result.HasPrevious = currentPage?.PreviousSibling != null;
                result.HasMore     = currentPage?.NextSibling != null;
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #6
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="key"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public override IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1)
        {
            var result = new ResourceSearchInfo(this)
            {
                Key       = key,
                PageIndex = pageindex,
                PageSize  = null
            };

            if (sortType == SortType.PubDate || sortType == SortType.FileSize)
            {
                result.SortType = sortType;
            }

            var url  = GetSearchUrl(key, sortType, sortDirection, pagesize, pageindex);
            var html = NetworkClient.Create <string>(HttpMethod.Get, url, _referUrl).Send();

            if (!html.IsValid())
            {
                return(null);
            }

            //分析
            var    strpos = 0;
            string row;

            while (!string.IsNullOrEmpty((row = html.Result.SearchStringTag("td class=\"idx\"", "</pre>", ref strpos))))
            {
                row = System.Web.HttpUtility.HtmlDecode(row);

                var hash = Regex.Match(row, @"info_hash=([a-f\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1).ToUpper();
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash;
                item.Provider = this;

                //标题
                item.Title        = Regex.Match(row, "torrent_name\".*?><.*?>(.*?)</a>", RegexOptions.IgnoreCase).GetGroupValue(1).DefaultForEmpty(".....");
                item.DownloadSize = Regex.Match(row, @"大小:</span>.*?attr_val"">([\d\.]+(&nbsp;|\s)+(\w+))", RegexOptions.IgnoreCase).GetGroupValue(1);
                //</span><span class="attr_val">179</span>
                item.FileCount      = Regex.Match(row, @"文件数:</span>.*?attr_val"">([\d\.,\s]+)", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt32();
                item.UpdateTimeDesc = Regex.Match(row, @"添加时间:</span>.*?attr_val"">([\d\.]+(&nbsp;|\s)+(\w+))", RegexOptions.IgnoreCase).GetGroupValue(1);

                result.Add(item);
            }

            result.HasPrevious = html.Result.IndexOf("\">← 上一个", StringComparison.OrdinalIgnoreCase) != -1;
            result.HasMore     = html.Result.IndexOf("\">下一个", StringComparison.OrdinalIgnoreCase) != -1;



            return(result);
        }
コード例 #7
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent"></param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (context.Response.Status == HttpStatusCode.MovedPermanently)
            {
                //Host切换了?
                var host = context.Response.Redirection.Current.Host;
                if (host != Host)
                {
                    Host = host;

                    result.RequestResearch = true;
                }

                return(false);
            }

            var doc  = CreateHtmlDocument(context.Result);
            var rows = doc.DocumentNode.SelectNodes("//table[@class='data']//tr[position()>1]");

            if (rows == null)
            {
                return(false);
            }

            foreach (var row1 in rows)
            {
                var magnet = row1.SelectSingleNode(".//a[contains(@title, 'magnet')]")?.GetAttributeValue("href", "");
                var hash   = Regex.Match(magnet, @"btih:([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);

                var titlelink = row1.SelectSingleNode(".//a[contains(@class,'cellMainLink')]");
                var title     = titlelink.InnerText;
                var size      = row1.SelectSingleNode("td[2]").InnerText.Trim();
                var files     = row1.SelectSingleNode("td[3]").InnerText.Trim().ToInt32();
                var age       = row1.SelectSingleNode("td[4]").InnerText.Trim();

                var res = CreateResourceInfo(hash, title);
                res.FileCount      = files;
                res.DownloadSize   = size;
                res.UpdateTimeDesc = age;

                //sitedata
                //kingsman-the-secret-service-2014-hc-hdrip-xvid-ac3-etrg-por-talamasca32-srt-t10610377.html
                var href = titlelink.GetAttributeValue("href", "");
                var info = Regex.Match(href, @"/(.+?)-t(\d+)\.html", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                res.SiteData = new SiteInfo()
                {
                    PageName = info.GetGroupValue(1),
                    SiteID   = info.GetGroupValue(2).ToInt64()
                };

                result.Add(res);
            }
            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = !doc.DocumentNode.SelectSingleNode("//div[contains(@class,'pages')]/a[last()]").GetAttributeValue("href", "").IsNullOrEmpty();

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #8
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (context.IsRedirection && context.Redirection.Orginal.Host != context.Redirection.Current.Host)
            {
                Host = context.Redirection.Current.Host;
                result.RequestResearch = true;
                return(false);
            }

            //分析
            var    strpos = 0;
            string row;

            //var nameMap = Regex.Matches(html.Result, @"map\[['""]([a-z\d]{40})[""']\].*?['""](.*?)[""'];", RegexOptions.IgnoreCase)
            //					.Cast<Match>().Where(s => s.Success).ToDictionary(s => s.Groups[1].Value, s => s.Groups[2].Value);

            while (!string.IsNullOrEmpty((row = context.Result.SearchStringTag("<div class=\"r\">", "磁力链接</span>", ref strpos))))
            {
                row = System.Web.HttpUtility.HtmlDecode(row);

                var hash = Regex.Match(row, @"/t/([a-f\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1).ToUpper();
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash;
                item.Provider = this;

                //标题
                item.Title = Regex.Match(row, "<h5.*?>(.*?)</h5>", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1);
                if (string.IsNullOrEmpty(item.Title))
                {
                    continue;
                }

                item.DownloadSize = Regex.Match(row, @"大小.*?>([\d\.]+\s*[^<\s]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1);
                item.FileCount    = Regex.Match(row, @"文件数:.*?>([\d\.\,]+\s*)", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1).ToInt32();
                item.UpdateTime   = Regex.Match(row, @"收录时间.*?>([\d\-]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1).ToDateTimeNullable();

                result.Add(item);
            }
            result.TotalPages  = Regex.Match(context.Result, @"totalPages\s*:\s*(\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1).ToInt32();
            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = result.PageIndex < result.TotalPages.Value;
            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #9
0
ファイル: TorrentSo.cs プロジェクト: wangkundo10/kubernetes
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="key"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public override IResourceSearchInfo Load(string key, SortType sortType, int sortDirection, int pagesize, int pageindex = 1)
        {
            var url   = $"http://api.xhub.cn/api.php?op=search_list&callback=jQuery{DateTime.Now.Ticks}&key={UE(key)}&page={pageindex}&_={DateTime.Now.ToJsTicks()}";
            var refer = GetSearchUrl(key, sortType, sortDirection, pagesize, pageindex);

            var result = CollectionUtility.CreateAnymousDictionary("", new { day = DateTime.Now, hits = 0, size = "", title = "" });
            var ctx    = NetworkClient.Create(HttpMethod.Get, url, refer, result: new
            {
                data   = result,
                total  = 0,
                status = 0
            }).Send();

            if (!ctx.IsValid())
            {
                return(null);
            }

            var items = new ResourceSearchInfo(this)
            {
                PageIndex  = pageindex,
                PageSize   = 30,
                TotalPages = (int)Math.Ceiling(ctx.Result.total / 30.0)
            };

            items.HasMore = pageindex < (items.TotalPages ?? 1);
            if (ctx.Result.data != null)
            {
                foreach (var item in ctx.Result.data)
                {
                    var res = CreateResourceInfo(item.Key, item.Value.title);
                    res.UpdateTime   = item.Value.day;
                    res.DownloadSize = item.Value.size;

                    items.Add(res);
                }
            }

            if (base.LoadCore(null, url, null, items))
            {
                return(items);
            }

            return(null);
        }
コード例 #10
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var document = CreateHtmlDocument(htmlContent);
            var tbody    = document.GetElementbyId("data_list");

            if (tbody == null)
            {
                return(false);
            }

            var nodes = tbody.SelectNodes("tr");

            foreach (var node in nodes)
            {
                var tds = node.SelectNodes("td");
                if (!(tds?.Count > 2))
                {
                    continue;
                }

                var titleLink = tds[2].SelectSingleNode("a");
                var title     = titleLink.InnerText;
                var href      = titleLink.GetAttributeValue("href", "");
                //show.php?hash=a86af7382b7f8fe4852cce9f98c29344c9d22993
                var hash = Regex.Match(href, @"hash=([a-f\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);
                var size = tds[3].InnerText;
                var time = tds[0].InnerText.Trim();

                var item = CreateResourceInfo(hash, title);
                item.SupportPreivewType = PreviewType.Image;
                item.UpdateTimeDesc     = time;
                item.DownloadSize       = size;
                item.SiteData           = new SiteInfo()
                {
                    ProvideSiteDownload = null
                };

                result.Add(item);
            }
            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = document.DocumentNode.SelectSingleNode("//a[@class='nextprev']") != null;

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #11
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var rows = doc.DocumentNode.SelectNodes("//ul[@class='table-list newly']/li");

            if (rows != null)
            {
                foreach (var row in rows)
                {
                    var link  = row.SelectSingleNode("./div[@class='name']/span[1]/a");
                    var dlink = row.SelectSingleNode("./div[@class='name']/a[contains(@class, 'btn-download')]");

                    //torrent/3344360/%5BCWPBD-76%5D.Actress.Kiss.Blow.Job.HD720p.mkv/
                    var linkinfo = Regex.Match(link.GetAttributeValue("href", ""), "torrent/(\\d+)/([^/]+)", RegexOptions.IgnoreCase);
                    var title    = link.InnerText;

                    var item         = CreateResourceInfo(null, title);
                    var downloadlink = dlink == null ? null : $"http://www.torrents.net/{(dlink.GetAttributeValue("href", ""))}";
                    item.SiteData = new SiteInfo()
                    {
                        SiteID              = linkinfo.GetGroupValue(1).ToInt64(),
                        PageName            = linkinfo.GetGroupValue(2),
                        ProvideSiteDownload = !string.IsNullOrEmpty(downloadlink),
                        SiteDownloadLink    = downloadlink
                    };
                    item.DownloadSize = row.SelectSingleNode("span[@class='size']")?.InnerText;

                    result.Add(item);
                }
            }

            var pagebar = doc.DocumentNode.SelectSingleNode("//div[@class='pagination-bar']");

            if (pagebar != null)
            {
                result.HasPrevious = pagebar.SelectSingleNode("a[1]/span/strike") == null;
                result.HasMore     = pagebar.SelectSingleNode("a[2]/span/strike") == null;
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #12
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(context.Result);

            var nodes = doc.DocumentNode.SelectNodes("//table[@class='table2'][last()]//tr[position()>1]");

            if (nodes == null)
            {
                return(false);
            }

            foreach (var node in nodes)
            {
                var a = node.SelectSingleNode("td[1]//a");
                if (a == null)
                {
                    continue;
                }
                var href = a.GetAttributeValue("href", "");
                //game-of-thrones-season-3/6f185a9f14a6ce7a3794c5dd1ef3dd51f0dc9f71
                var m = Regex.Match(href, @"/([^/]+)/([a-f\d]{40})", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }

                var item = CreateResourceInfo(m.GetGroupValue(2), a.InnerText);
                item.SiteData = new SiteInfo()
                {
                    PageName = m.GetGroupValue(1)
                };
                item.UpdateTimeDesc = node.SelectSingleNode("td[2]").InnerText;
                item.DownloadSize   = node.SelectSingleNode("td[3]").InnerText;

                result.Add(item);
            }
            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = doc.GetElementbyId("next") != null;

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #13
0
        void ParserSearchPageHtml(string html, ResourceSearchInfo result)
        {
            string bodyContent;

            if (string.IsNullOrEmpty(html) || string.IsNullOrEmpty((bodyContent = html.SearchStringTag("<table class=\"list\" width=\"100%\">", "</table>"))))
            {
                return;
            }

            bodyContent = RemoveEmailProtect(bodyContent);

            string rowContent;
            var    charPosition = 0;

            while (!string.IsNullOrEmpty((rowContent = bodyContent.SearchStringTag("<tr", "</tr>", ref charPosition))))
            {
                var hash = Regex.Match(rowContent, @"value=['""]([a-f\d]{40})['""]", RegexOptions.IgnoreCase).GetGroupValue(1);
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash.ToUpper();
                item.Provider = this;

                //标题
                var title = Regex.Match(rowContent, @"<a.*?href=['""].*?/(\d+)/([^'""]+?)\.html['""]>(.*?)</a>", RegexOptions.IgnoreCase);
                item.Title    = title.GetGroupValue(3).DefaultForEmpty(".....");
                item.SiteData = new SiteInfo()
                {
                    PageName = title.GetGroupValue(2),
                    SiteID   = title.GetGroupValue(1).ToInt64()
                };
                item.DownloadSize   = RemoveSpaceChars(Regex.Match(rowContent, @"nowrap>\s*(([\d\.]+).*?B)\s*<", RegexOptions.IgnoreCase).GetGroupValue(1) ?? "");
                item.UpdateTimeDesc = Regex.Match(rowContent, "class=\"light\">([^><]+)</td>", RegexOptions.IgnoreCase).GetGroupValue(1);

                result.Add(item);
            }

            result.HasPrevious = html.IndexOf("paging_prev", StringComparison.OrdinalIgnoreCase) != -1;
            result.HasMore     = html.IndexOf("paging_next", StringComparison.OrdinalIgnoreCase) != -1;
        }
コード例 #14
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var items = doc.DocumentNode.SelectNodes("//table[@class='table2'][2]//tr[position()>1]");

            if (items != null)
            {
                foreach (var item in items)
                {
                    var dlink = item.SelectSingleNode("td[1]/div/a[1]");
                    var tlink = item.SelectSingleNode("td[1]/div/a[2]");
                    var dcell = item.SelectSingleNode("td[2]");
                    var scell = item.SelectSingleNode("td[3]");

                    //hash
                    var hash  = Regex.Match(dlink.GetAttributeValue("href", ""), @"torrent/([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);
                    var pinfo = Regex.Match(tlink.GetAttributeValue("href", ""), @"/([^/]+?)\-(\d+)\.html", RegexOptions.IgnoreCase);

                    var resnode = CreateResourceInfo(hash, tlink.InnerText);
                    resnode.SiteData = new SiteInfo()
                    {
                        PageName = pinfo.GetGroupValue(1),
                        SiteID   = pinfo.GetGroupValue(2).ToInt64()
                    };
                    resnode.UpdateTimeDesc = dcell.InnerText.Split('-')[0].Trim();
                    resnode.DownloadSize   = scell.InnerText;

                    result.Add(resnode);
                }
            }

            var pager = doc.DocumentNode.SelectSingleNode("//div[@class='search_stat']");

            if (pager != null)
            {
                result.HasMore     = pager.SelectSingleNode("./*[last()]")?.Name == "a";
                result.HasPrevious = pager.SelectSingleNode("./*[1]")?.Name == "a";
            }
            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #15
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var nodes = doc.DocumentNode.SelectNodes("//div[@class='inner_container']//div[contains(@class,'grey_bar3')]");

            if (nodes != null)
            {
                foreach (var node in nodes)
                {
                    var titlelink = node.SelectSingleNode("p/a");
                    if (titlelink == null || titlelink.GetAttributeValue("href", "").IndexOf("torrent/", StringComparison.Ordinal) == -1)
                    {
                        continue;
                    }

                    var link = titlelink.GetAttributeValue("href", "");
                    //torrent/1653923478/Game+of+Thrones+S02E05+The+Ghost+Of+Harrenhal+HDTV+XviD-2HD+%5Beztv%5D
                    var linkreg = Regex.Match(link, @"torrent/(\d+)/(.+)", RegexOptions.IgnoreCase);
                    var data    = new SiteInfo()
                    {
                        SiteID   = linkreg.GetGroupValue(1).ToInt64(),
                        PageName = UD(linkreg.GetGroupValue(2))
                    };
                    var title = titlelink.InnerText;
                    var size  = node.SelectSingleNode("span[4]").InnerText;

                    var item = CreateResourceInfo(null, title);
                    item.DownloadSize = size;
                    item.SiteData     = data;

                    result.Add(item);
                }
            }
            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = htmlContent.IndexOf("rel=\"nofollow\">&gt;&gt;</a></li>") != -1;


            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #16
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var div = doc.GetElementbyId("serps");

            if (div == null)
            {
                return(false);
            }

            var rows       = div.SelectNodes("//tr[@data-key!='']");
            var downloader = AppContext.Instance.DownloadServiceProviders.FirstOrDefault(s => s is IsoHuntDownloadProvider);

            foreach (var row in rows)
            {
                var titleLink = row.SelectSingleNode("td[2]/a[1]");
                var item      = new ResourceInfo()
                {
                    Title    = titleLink.InnerText,
                    Provider = this,
                    PreferDownloadProvider = downloader,
                    UpdateTimeDesc         = row.ChildNodes[4].InnerText,
                    DownloadSize           = row.ChildNodes[5].InnerText
                };

                var href     = titleLink.Attributes["href"].Value;
                var hrefInfo = Regex.Match(href, @"torrent_details/(\d+)/([^'""]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                item.SiteData = new SiteInfo()
                {
                    SiteID   = hrefInfo.Groups[1].Value.ToInt64(),
                    PageName = hrefInfo.Groups[2].Value
                };

                result.Add(item);
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #17
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (!context.IsValid())
            {
                return(false);
            }

            var doc   = CreateHtmlDom(context.Request.Uri.ToString(), context.Result);
            var nodes = doc.Find(@"table.search_table tr");

            if (nodes != null)
            {
                foreach (var node in nodes.Skip(1))
                {
                    var link = node.FindFirstOrDefault("td:last-child a");
                    var href = link.GetAttributeValue("href");

                    var infoMatch = Regex.Match(href, @"\|file\|([^\|]+)\|(\d+)\|([A-Z\d]+)\|");

                    var res = CreateResourceInfo(infoMatch.GetGroupValue(3), infoMatch.GetGroupValue(1), ResourceType.Ed2K);
                    res.DownloadSizeValue = infoMatch.GetGroupValue(2).ToInt64();

                    //preview
                    var preview = node.FindFirstOrDefault("td:nth-child(2) img");
                    if (preview?.GetAttributeValue("src")?.IndexOf("hexie") != -1)
                    {
                        res.SupportPreivewType = PreviewType.Image;
                        res.PreviewInfo        = new PreviewInfo()
                        {
                            ImageUrl = $"http://thumb.donkey4u.com/{res.Hash}/thumb.jpg"
                        };
                    }

                    result.Add(res);
                }

                result.HasMore = context.Result.IndexOf("&mode=list\">下一页") != -1;
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #18
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc   = CreateHtmlDocument(htmlContent);
            var table = doc.DocumentNode.SelectNodes("//div[@id='headerbox']/following::table")?.LastOrDefault(s => s.SelectSingleNode(".//tr[1]/th[6]") != null);
            var rows  = table?.SelectNodes(".//tr[position()>1]");

            if (rows != null)
            {
                foreach (var row in rows)
                {
                    var titlelink = row.SelectSingleNode("td[1]/a");
                    var title     = titlelink.InnerText;
                    var pinfo     = Regex.Match(titlelink.GetAttributeValue("href", ""), @"details/(\d+)/(.*?)\.html", RegexOptions.IgnoreCase);
                    if (!pinfo.Success)
                    {
                        continue;
                    }

                    var item = CreateResourceInfo(null, title);
                    item.SiteData = new SiteInfo()
                    {
                        SiteID   = pinfo.GetGroupValue(1).ToInt64(),
                        PageName = pinfo.GetGroupValue(2)
                    };
                    item.UpdateTimeDesc = row.SelectSingleNode("td[2]").InnerText;
                    item.DownloadSize   = row.SelectSingleNode("td[3]").InnerText;

                    result.Add(item);
                }

                var pagination = doc.GetElementbyId("pagination");
                if (pagination != null)
                {
                    var cp = pagination.SelectSingleNode("a[@class='selected']");
                    result.HasMore     = cp.NextSibling != null;
                    result.HasPrevious = cp.PreviousSibling != null;
                }
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #19
0
        void ParserSearchPageHtml(string html, ResourceSearchInfo result)
        {
            string bodyContent;

            if (string.IsNullOrEmpty(html) || string.IsNullOrEmpty((bodyContent = html.SearchStringTag("<table class=\"table\">", "</table>"))))
            {
                return;
            }

            string rowContent;
            var    charPosition = 0;

            while (!string.IsNullOrEmpty((rowContent = bodyContent.SearchStringTag("<tr>", "</tr>", ref charPosition))))
            {
                var hash = Regex.Match(rowContent, @"btih:(\w{40})", RegexOptions.IgnoreCase).GetGroupValue(1);
                if (string.IsNullOrEmpty(hash))
                {
                    continue;
                }

                var item = new ResourceInfo();
                item.Hash     = hash.ToUpper();
                item.Provider = this;
                item.SiteData = new SiteInfo()
                {
                    SiteID = Regex.Match(rowContent, @"/h/(\d+)", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt64()
                };

                //标题
                item.Title          = RemoveHtmlStrings(Regex.Match(rowContent, @"<div>[\s]*<a.*?class=['""]title['""].*?>(.*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1).DefaultForEmpty("....."));
                item.DownloadSize   = RemoveSpaceChars(Regex.Match(rowContent, @"大小\s*:\s*([\d\.]+\s*[A-Z]+)", RegexOptions.IgnoreCase).GetGroupValue(1));
                item.UpdateTimeDesc = Regex.Match(rowContent, @"更新时间:\s*<span.*?>(.*?)</span>", RegexOptions.IgnoreCase).GetGroupValue(1) ?? "";
                item.FileCount      = Regex.Match(rowContent, @"文件数\s*:\s*([\d\.,]+)", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt32();

                result.Add(item);
            }

            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = result.Count > 0 && html.IndexOf("<li class=\"disabled\"><a href=\"#\"> Next", StringComparison.OrdinalIgnoreCase) == -1;
        }
コード例 #20
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var document = CreateHtmlDocument(htmlContent);
            var nodes    = document.DocumentNode.SelectNodes("//table[@class='tor'][last()]//tr[position()>1]");

            foreach (var node in nodes)
            {
                var titlelink = node.SelectSingleNode("td[1]/a");
                var href      = titlelink.GetAttributeValue("href", "");
                var hrefm     = Regex.Match(href, @"/(.*?)\-tf(\d+)\.html", RegexOptions.IgnoreCase);
                if (!hrefm.Success)
                {
                    continue;
                }

                var title    = titlelink.InnerText;
                var sid      = hrefm.GetGroupValue(2).ToInt64();
                var pagename = hrefm.GetGroupValue(1);
                var size     = node.SelectSingleNode("td[2]").InnerText;
                var update   = node.SelectSingleNode("td[5]").InnerText;

                var resinfo = CreateResourceInfo(null, title);
                resinfo.DownloadSize   = size;
                resinfo.UpdateTimeDesc = update;
                resinfo.SiteData       = new SiteInfo()
                {
                    SiteID   = sid,
                    PageName = pagename
                };

                result.Add(resinfo);
            }

            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = document.GetElementbyId("pgright") != null;

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #21
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var list = doc.DocumentNode.SelectSingleNode("//table[@class='searchtable'][last()]");

            if (list == null)
            {
                return(false);
            }

            var rows = list.SelectNodes(".//tr[position()>1]");

            foreach (var row in rows)
            {
                var titleLink = row.SelectSingleNode("td[1]/a[1]");
                //移除类别节点
                titleLink.SelectSingleNode("span[@class='cat']")?.Remove();

                var item = CreateResourceInfo(Regex.Match(titleLink.Attributes["href"].Value, "hash/([a-z\\d]{40})", RegexOptions.IgnoreCase | RegexOptions.Singleline).GetGroupValue(1), titleLink.InnerText);

                item.UpdateTimeDesc = row.SelectSingleNode("td/span[contains(@class,'added')]/text()").InnerText;
                item.DownloadSize   = row.SelectSingleNode("td/span[contains(@class,'size')]").InnerText;

                result.Add(item);
            }
            var pageDiv = doc.DocumentNode.SelectSingleNode("//div[@class='pagediv']/ul");

            if (pageDiv != null)
            {
                result.HasPrevious = pageDiv.SelectSingleNode("li[1]/a") != null;
                result.HasMore     = pageDiv.SelectSingleNode("li[3]/a") != null;
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #22
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var rootNode = doc.GetElementbyId("torrents");

            if (rootNode == null)
            {
                return(true);
            }

            var items = rootNode.SelectNodes("li");

            foreach (var item in items)
            {
                var titlelink = item.SelectSingleNode("a[1]");
                var href      = Regex.Match(titlelink.Attributes["href"].Value, "/([^\\s\'\"]+?)\\-q(\\d+)\\.html", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                var descNode  = item.SelectSingleNode(".//table//td[1]");
                var size      = descNode.SelectSingleNode("text()")?.InnerText ?? "";
                var filecount = Regex.Match(descNode.SelectSingleNode("div").InnerText ?? "", @"(\d+)\s*files").GetGroupValue(1).ToInt32();

                var res = CreateResourceInfo(null, titlelink.InnerText);
                res.DownloadSize = size;
                res.FileCount    = filecount;
                res.SiteData     = new SiteInfo()
                {
                    PageName = href.GetGroupValue(1),
                    SiteID   = href.GetGroupValue(2).ToInt64()
                };

                result.Add(res);
            }


            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #23
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var nodes = doc.DocumentNode.SelectNodes("//article/table[last()]//tr[position()>1]");

            if (nodes != null)
            {
                foreach (var node in nodes)
                {
                    var titlelink = node.SelectSingleNode("td[1]//a");
                    //torrent/2733310/1pondo-011014_734-hd.html
                    var siteinfoReg = Regex.Match(titlelink.GetAttributeValue("href", ""), @"torrent/(\d+)/(.*?)\.html");

                    var item = CreateResourceInfo(null, titlelink.InnerText);
                    item.SiteData = new SiteInfo()
                    {
                        SiteID              = siteinfoReg.GetGroupValue(1).ToInt64(),
                        PageName            = siteinfoReg.GetGroupValue(2),
                        ProvideSiteDownload = true,
                        SiteDownloadLink    = $"https://www.torlock.com/tor/{siteinfoReg.GetGroupValue(1).ToInt64()}.torrent"
                    };

                    item.UpdateTimeDesc = node.SelectSingleNode("td[2]")?.InnerText;
                    item.UpdateTime     = item.UpdateTimeDesc.ToDateTimeNullable();
                    item.DownloadSize   = node.SelectSingleNode("td[3]")?.InnerText;

                    result.Add(item);
                }
            }
            result.HasPrevious = doc.DocumentNode.SelectSingleNode("//div[@id='pag']/a[@class='sel']/preceding-sibling::*") != null;
            result.HasMore     = doc.DocumentNode.SelectSingleNode("//div[@id='pag']/a[@class='sel']/following-sibling::*") != null;

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #24
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            //分析
            var content = context.Result.SearchStringTag("<div class=\"SimpleAcceptebleTextAds\">", "Web search results");

            if (!content.IsNullOrEmpty())
            {
                var matches = Regex.Matches(content, @"<dl><dt><a.*?/([a-z\d]{40})"".*?>(.*?)</a>.*?<span\sclass=""a"">.*?title=""([^""]+)"".*?class=""s"">([^<>]+)<.*?</dl>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
                foreach (Match match in matches)
                {
                    var item = new ResourceInfo();
                    item.Hash         = match.GetGroupValue(1).ToUpper();
                    item.Provider     = this;
                    item.Title        = match.GetGroupValue(2);
                    item.DownloadSize = match.GetGroupValue(4);
                    item.UpdateTime   = match.GetGroupValue(3).ToDateTimeNullable();

                    result.Add(item);
                }
                result.HasPrevious = context.Result.IndexOf("\">&laquo; Previous") != -1;
                result.HasMore     = context.Result.IndexOf("\">Next &raquo;") != -1;
            }
            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #25
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (context.IsRedirection)
            {
                var nHost = context.Redirection.Current.Host;
                if (nHost != Host)
                {
                    Host = nHost;
                    result.RequestResearch = true;
                }
                return(false);
            }
            htmlContent = DecodePage(htmlContent);

            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            //节点
            var nodes = doc.DocumentNode.SelectNodes(@"//div[@class='list-con']/dl");

            if (nodes != null)
            {
                foreach (HtmlNode node in nodes)
                {
                    var titleLink = node.SelectSingleNode("dt/a");
                    if (titleLink == null)
                    {
                        continue;
                    }

                    //pageid;http://btkitty.org/item/BcGBAQAgBATAlco_MY7Q_iN0t40SBXlwtA7jRqUsZ_no4YHR0qQ_.html
                    var pageinfo = Regex.Match(titleLink.GetAttributeValue("href", ""), @"/([^/]+?)/([^/]+?)\.html", RegexOptions.IgnoreCase);
                    var pageid   = pageinfo.GetGroupValue(2);
                    _itemPageKey = pageinfo.GetGroupValue(1).DefaultForEmpty(_itemPageKey);
                    var title = titleLink.InnerText;

                    //detail spans.
                    var detailSpans = node.SelectNodes("dd[@class='option']/span");
                    //hash
                    var hash = Regex.Match(detailSpans[0].SelectSingleNode("a").GetAttributeValue("href", ""), @"([A-F\d]{40})").GetGroupValue(1);
                    //date
                    var date = detailSpans[1].SelectSingleNode("b").InnerText;
                    //size
                    var size = detailSpans[2].SelectSingleNode("b").InnerText;
                    //fc
                    var fc = Regex.Match(detailSpans[3].SelectSingleNode("b").InnerText, @"(\d+)").GetGroupValue(1).ToInt32();

                    var item = CreateResourceInfo(hash, title);
                    item.FileCount      = fc;
                    item.DownloadSize   = size;
                    item.UpdateTimeDesc = date;
                    item.SiteData       = new SiteInfo()
                    {
                        SiteID              = 0L,
                        PageName            = pageid,
                        ProvideSiteDownload = true,
                        SiteDownloadLink    = $"http://storebt.com/down/{pageid}/torrent.torrent"
                    };

                    result.Add(item);
                }
            }
            //hasmore?
            result.HasPrevious = result.PageIndex > 1;

            var totalPage = Regex.Match(htmlContent, @"<span>共\s*(\d+)\s*页</span>", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt32();

            result.HasMore = totalPage > result.PageIndex;


            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #26
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (IsHostChanged(context))
            {
                result.RequestResearch = true;
                return(false);
            }
            if (IsBotCheckNeeded(context))
            {
                if (RequireBotCheck())
                {
                    result.RequestResearch = true;
                }

                return(false);
            }

            var doc = CreateHtmlDom(url, htmlContent);

            var rows = doc.Find("table.lista2t tr").Skip(1);

            foreach (var row in rows)
            {
                var titlelink = row.FindFirstOrDefault("td:nth-child(2) a");
                var titleHref = titlelink.GetAttributeValue("href");
                //如果是提供的直接下载,则忽略。这个是广告。
                if (titleHref.IsNullOrEmpty() || titleHref.IndexOf("torrent") == -1)
                {
                    continue;
                }

                //基本信息
                ///torrent/zxv627d
                var sidstr = Regex.Match(titlelink.GetAttributeValue("href"), @"torrent/([\da-z]+)", RegexOptions.IgnoreCase).GetGroupValue(1);
                var hash   = Regex.Match(titlelink.GetAttributeValue("onmouseover") ?? "", @"/([a-z\d]{40})", RegexOptions.IgnoreCase).GetGroupValue(1);
                if (hash.IsNullOrEmpty())
                {
                    continue;
                }

                var title = titlelink.InnerText();

                var size = row.FindFirstOrDefault("td:nth-child(4)").InnerText();
                var date = row.FindFirstOrDefault("td:nth-child(3)").InnerText().Trim().ToDateTimeNullable();

                var item = CreateResourceInfo(hash, title);
                item.DownloadSize = size;
                item.UpdateTime   = date;
                item.SiteData     = new SiteInfo()
                {
                    SiteID              = 0L,
                    PageName            = sidstr,
                    ProvideSiteDownload = true,
                    SiteDownloadLink    = $"https://{Host}/download.php?id={sidstr}&f={title}.torrent"
                };

                //预览信息
                var mouseout = titlelink.GetAttributeValue("onmouseover");
                if (!mouseout.IsNullOrEmpty())
                {
                    var imgsrc = Regex.Match(mouseout, @"<img.*?src=.*?//([^'""\\]+)").GetGroupValue(1);
                    if (!imgsrc.IsNullOrEmpty())
                    {
                        item.SupportPreivewType = PreviewType.Image;
                        item.PreviewInfo        = new PreviewInfo()
                        {
                            ImageUrl = $"http://dyncdn.me/posters2/{hash[0]}/{hash}.jpg"
                        };
                    }
                }

                result.Add(item);
            }

            var pager = doc.FindFirstOrDefault("div#pager_links");

            if (pager != null)
            {
                result.HasPrevious = pager.FindFirstOrDefault("*:first-child")?.Name == "a";
                result.HasMore     = pager.FindFirstOrDefault("*:last-child")?.Name == "a";
            }

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #27
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            //节点
            var nodes = doc.DocumentNode.SelectNodes(@"//div[@class='item']");

            if (nodes != null)
            {
                foreach (HtmlNode node in nodes)
                {
                    var titleLink = node.SelectSingleNode("div[@class='item-title']/a");
                    if (titleLink == null)
                    {
                        continue;
                    }

                    //pageid;http://diggbt.com/item/BcEBDQAwCAMwSx9h5HbGOP4lvO206MSCOsT1qDCMjiKbAz0Z3g8.html
                    var pageinfo = Regex.Match(titleLink.GetAttributeValue("href", ""), @"/([^/]+?)/([^/]+?)\.html", RegexOptions.IgnoreCase);
                    var pageid   = pageinfo.GetGroupValue(2);
                    _itemPageKey = pageinfo.GetGroupValue(1).DefaultForEmpty(_itemPageKey);
                    var title = titleLink.InnerText;

                    //detail spans.
                    var detailSpans = node.SelectNodes("div[@class='item-detail']/span");
                    //hash
                    //var hash = Regex.Match(detailSpans[0].SelectSingleNode("a").GetAttributeValue("href", ""), @"([A-F\d]{40})").GetGroupValue(1);
                    var hash = Regex.Replace(Regex.Match(detailSpans[0].SelectSingleNode("script").InnerText, @":([a-f'""\+\d]+)&", RegexOptions.IgnoreCase).GetGroupValue(1), @"['""+]", "").Trim('&', ':');
                    //date
                    var date = detailSpans[1].SelectSingleNode("b").InnerText;
                    //size
                    var size = detailSpans[2].SelectSingleNode("b").InnerText;
                    //fc
                    var fc = Regex.Match(detailSpans[3].SelectSingleNode("b").InnerText, @"(\d+)").GetGroupValue(1).ToInt32();

                    var item = CreateResourceInfo(hash, title);
                    item.FileCount      = fc;
                    item.DownloadSize   = size;
                    item.UpdateTimeDesc = date;
                    item.SiteData       = new SiteInfo()
                    {
                        SiteID              = 99999999999L,
                        PageName            = pageid,
                        ProvideSiteDownload = true,
                        SiteDownloadLink    = $"http://storebt.com/down/{pageid}/torrent.torrent"
                    };

                    result.Add(item);
                }
            }
            //hasmore?
            result.HasPrevious = result.PageIndex > 1;

            var totalPage = Regex.Match(htmlContent, @"<span>共\s*(\d+)\s*页</span>", RegexOptions.IgnoreCase).GetGroupValue(1).ToInt32();

            result.HasMore = totalPage > result.PageIndex;


            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #28
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var doc       = CreateHtmlDocument(context.Result);
            var seedTable = doc.DocumentNode.SelectSingleNode("//table[contains(@class,'seedtable')]");

            if (seedTable == null)
            {
                return(false);
            }

            var nodes = seedTable.SelectNodes(".//tr[position()>2 and position()<last()]");

            if (nodes == null)
            {
                return(true);
            }


            foreach (var node in nodes)
            {
                var a       = node.SelectSingleNode("td[2]/a");
                var title   = a.InnerText;
                var sid     = Regex.Match(a.GetAttributeValue("href", ""), @"(?<=/)\d+(?=\.html)", RegexOptions.IgnoreCase).Value.ToInt32();
                var sizestr = node.SelectSingleNode("td[4]").InnerText.Trim();

                var downloads = node.SelectNodes("td[3]/a");
                var hasmulti  = downloads.Count > 1;

                //parent?
                ResourceInfo        parent = null;
                List <ResourceInfo> subRes = null;
                if (hasmulti)
                {
                    parent = new ResourceInfo()
                    {
                        Title           = title,
                        HasSubResources = true,
                        SiteData        = new SiteInfo()
                        {
                            SiteID = sid
                        },
                        DownloadSize = sizestr,
                        Provider     = this,
                        ResourceType = ResourceType.MultiResource
                    };
                    subRes = new List <ResourceInfo>();
                }

                long?size = null;
                foreach (var subnode in downloads)
                {
                    var href = subnode.GetAttributeValue("href", "");

                    if (href.IndexOf("ed2k://") == 0)
                    {
                        var reg = Regex.Match(href, "\\|file\\|([^\\|]+)\\|(\\d+)\\|([a-z\\d]+)", RegexOptions.IgnoreCase);
                        if (!reg.Success)
                        {
                            continue;
                        }

                        var filename = UD(reg.GetGroupValue(1)).Trim();
                        var hash     = reg.GetGroupValue(3);
                        size = reg.GetGroupValue(2).ToInt64();

                        var res = CreateResourceInfo(hash, filename, ResourceType.Ed2K);
                        res.DownloadSizeValue = size;
                        //重置其它的Resource
                        if (parent != null)
                        {
                            parent.DownloadSizeValue = size;
                        }
                        subRes?.ForEach(s => s.DownloadSizeValue = size);

                        if (subRes != null)
                        {
                            subRes.Add(res);
                        }
                        else
                        {
                            result.Add(res);
                        }
                    }
                    else if (href.IndexOf("magnet:") == 0)
                    {
                        var reg = Regex.Match(href, "btih:([a-f\\d]{40})", RegexOptions.IgnoreCase);
                        if (!reg.Success)
                        {
                            continue;
                        }

                        var filename = UD(title).Trim();
                        var hash     = reg.GetGroupValue(1);

                        var res = CreateResourceInfo(hash, filename, ResourceType.BitTorrent);
                        res.DownloadSize      = sizestr;
                        res.DownloadSizeValue = size;

                        if (subRes != null)
                        {
                            subRes.Add(res);
                        }
                        else
                        {
                            result.Add(res);
                        }
                    }
                    else if (href.IndexOf("pan.baidu.com") != -1 || href.IndexOf("urlxf.qq.com") != -1 || href.IndexOf("kuai.xunlei.com") != -1 || href.IndexOf("yunpan.cn") != -1)
                    {
                        var type = href.IndexOf("pan.baidu.com") != -1 ? NetDiskType.BaiduDesk :
                                   href.IndexOf("urlxf.qq.com") != -1 ? NetDiskType.QqXf :
                                   href.IndexOf("kuai.xunlei.com") != -1 ? NetDiskType.XlShare : NetDiskType.QihuShare;
                        //百度网盘, 旋风分享, 迅雷快传
                        var res = CreateResourceInfo(null, title, ResourceType.NetDisk);
                        res.DownloadSize      = sizestr;
                        res.DownloadSizeValue = size;
                        res.NetDiskData       = new NetDiskData()
                        {
                            NetDiskType = type,
                            Url         = href
                        };

                        if (subRes != null)
                        {
                            subRes.Add(res);
                        }
                        else
                        {
                            result.Add(res);
                        }
                    }
                }

                if (parent != null)
                {
                    if (subRes.Count > 1)
                    {
                        parent.SubResources = subRes.Cast <IResourceInfo>().ToArray();
                        result.Add(parent);
                    }
                    else if (subRes.Count > 0)
                    {
                        result.Add(subRes[0]);
                    }
                }
            }

            result.HasMore     = context.Result.IndexOf(">下一页") != -1;
            result.HasPrevious = result.PageIndex > 1;


            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #29
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            var document = CreateHtmlDocument(htmlContent);
            var nodes    = document.GetElementbyId("main")?.SelectNodes("ul/li");

            if (nodes == null)
            {
                return(false);
            }

            foreach (var node in nodes)
            {
                var thumb     = node.SelectSingleNode("div[@class='thumb']/a");
                var titlelink = node.SelectSingleNode("div[@class='list_info']//h4/a");
                if (titlelink == null)
                {
                    continue;
                }

                var item = CreateResourceInfo(null, titlelink.GetAttributeValue("title", ""), ResourceType.MultiResource);
                //<a href="/emule/download/2148521356" title="《权力的游戏 第五季》(Game of Thrones Season 5)[HDTVrip,WEBRip,720P,1080P]更新第9集">《<em class="highlight">权力的游戏</em> 第五季》(Game of Thrones Season 5)[HDTVrip,WEBRip,720P,1080P]更新第9集</a>
                item.SiteData = new SiteInfo()
                {
                    SiteID = Regex.Match(titlelink.GetAttributeValue("href", ""), @"\d+").Value.ToInt64()
                };
                //预览信息
                if (thumb != null)
                {
                    var style = thumb.GetAttributeValue("style", "");
                    if (style != null)
                    {
                        //background-image: url(http://thumb.icili.com/2148521356.jpg)
                        var pm = Regex.Match(style, @"url\(['""]?([^\)]+)['""]?\)");
                        if (pm.Success)
                        {
                            item.SupportPreivewType = PreviewType.Image;
                            item.PreviewInfo        = new PreviewInfo()
                            {
                                ImageUrl = pm.GetGroupValue(1)
                            };
                        }
                    }
                }
                var introText = node.SelectSingleNode("div[@class='list_info']").InnerText;
                //发布时间:2015-4-12 19:18 更新时间:2015-6-9 0:19
                item.UpdateTimeDesc = Regex.Match(introText, @"发布时间.*?([\d-_]+\s*[\d-_:])").GetGroupValue(1);
                // 文件数:44 | 点击数:2409
                item.FileCount = Regex.Match(introText, @"文件数[\s:]*?([\d]+)").GetGroupValue(1).ToInt32Nullable();

                item.HasSubResources = true;
                item.ResourceType    = ResourceType.MultiResource;
                result.Add(item);
            }
            result.HasPrevious = result.PageIndex > 1;

            var nextAnchor = document.DocumentNode.SelectSingleNode("//div[@class='pager']//a[last()]");

            result.HasMore = nextAnchor != null && nextAnchor.GetAttributeValue("disabled", "") != "disabled";

            return(base.LoadCore(context, url, htmlContent, result));
        }
コード例 #30
0
        /// <summary>
        /// 核心加载
        /// </summary>
        /// <param name="context"></param>
        /// <param name="url"></param>
        /// <param name="htmlContent">HTML内容</param>
        /// <param name="result">目标结果</param>
        /// <returns></returns>
        protected override bool LoadCore(HttpContext <string> context, string url, string htmlContent, ResourceSearchInfo result)
        {
            if (!base.LoadCore(context, url, htmlContent, result))
            {
                return(false);
            }

            var doc = new HtmlDocument();

            doc.LoadHtml(htmlContent);

            var listTable = doc.DocumentNode.SelectSingleNode("//table");

            if (listTable == null)
            {
                return(true);
            }

            var rows       = listTable.SelectNodes("tbody/tr[not(contains(@class, 'success'))]");
            var downloader = AppContext.Instance.DownloadServiceProviders.FirstOrDefault(s => s is MonovaDownloadProvider);

            if (rows != null)
            {
                foreach (HtmlNode row in rows)
                {
                    //var cls = row.GetAttributeValue("class", "");
                    //if (!cls.IsNullOrEmpty() && cls.IndexOf("success", StringComparison.OrdinalIgnoreCase) != -1)
                    //	continue;

                    var namelink = row.SelectSingleNode("td[1]/a");
                    var link     = namelink.Attributes["href"].Value;
                    var name     = namelink.InnerText;

                    var item = new ResourceInfo()
                    {
                        Title                  = name,
                        Provider               = this,
                        UpdateTimeDesc         = row.SelectSingleNode("td[6]").InnerText,
                        DownloadSize           = row.SelectSingleNode("td[5]").InnerText,
                        PreferDownloadProvider = downloader
                    };

                    var info = Regex.Match(link, @"torrent/(\d+)/([^""]*?)\.html", RegexOptions.IgnoreCase);
                    //可能是广告链接
                    if (!info.Success)
                    {
                        continue;
                    }
                    item.SiteData = new SiteInfo()
                    {
                        SiteID   = info.Groups[1].Value.ToInt64(),
                        PageName = info.Groups[2].Value
                    };

                    result.Add(item);
                }
            }

            //分页

            result.HasPrevious = result.PageIndex > 1;
            result.HasMore     = (doc.DocumentNode.SelectSingleNode("//ul[contains(@class,'pagination')]/li[last()]")?.GetAttributeValue("class", "") ?? "active").IndexOf("active", StringComparison.OrdinalIgnoreCase) == -1;

            return(base.LoadCore(context, url, htmlContent, result));
        }