protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { //if (!string.IsNullOrEmpty(requeststr) // && item != null) //{ // HtmlDocument document = new HtmlDocument(); // document.LoadHtml(requeststr); // HtmlNode node = document.GetElementbyId("magnetLink"); // if (node != null) // { // item.MagneticLink = node.InnerText; // } //} } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count == 0) { this.IsFinished = true; } foreach (Match item in itemmatchs) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; HtmlDocument document = new HtmlDocument(); document.LoadHtml(item.Value); var head = document.DocumentNode.SelectNodes("/li/div/h4/a"); if (head.Count > 0) { HtmlNode first = head[0]; string title = first.GetAttributeValue("rel", ""); for (int i = 0; i < 3; i++) { title = Encoding.UTF8.GetString(Convert.FromBase64String(title)); } resultItem.Title = title; if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.MagneticLink = "magnet:?xt=urn:btih:" + first.GetInnerText("/li/div/h4/a"); resultItem.DetailUrl = this.WebUrl + first.GetAttributeValue("href", ""); } resultItem.ResourceType = "未知"; resultItem.CreateTime = document.DocumentNode.GetInnerText("/li/div/div/span[1]"); resultItem.Size = document.DocumentNode.GetInnerText("/li/div/div/span[2]"); resultItem.HotLevel = document.DocumentNode.GetInnerText("/li/div/div/span[3]"); this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); HtmlNode node = document.GetElementbyId("content"); if (node != null) { item.Title = node.GetInnerText(node.XPath + "/div[1]/h1[1]"); item.CreateTime = node.GetInnerText(node.XPath + "/div[1]/div[1]/p[3]").Replace("收录时间:", ""); item.MagneticLink = node.GetFirstAttrText(node.XPath + "/div[1]/div[1]/p[6]/a[1]", "href"); HtmlNodeCollection filelistnodes = node.SelectNodes("//ol/li"); if (filelistnodes != null && filelistnodes.Count > 0) { for (int i = 0; i < filelistnodes.Count; i++) { string text = filelistnodes[i].InnerText; string size = null; if (filelistnodes[i].HasChildNodes) { HtmlNode sizenode = filelistnodes[i].ChildNodes.FindFirst("span"); if (sizenode != null) { size = sizenode.InnerText; text = text.RemoveEnd(size); } } item.AddFileItem(new FileItem { Index = i + 1, FileName = text, Size = size }); } } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { Stopwatch sw = Stopwatch.StartNew(); HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); var items = document.DocumentNode.SelectNodes("//div[@class='panel panel-default']").Where(_p => _p.HasChildNodes && _p.ChildNodes.Count == 3); if (!items.Any()) { this.IsFinished = true; } foreach (var item in items) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; var head = document.DocumentNode.SelectSingleNode(item.XPath + "/div[1]/h5[1]/a[1]"); if (head != null) { resultItem.Title = head.InnerText; resultItem.DetailUrl = this.WebUrl + head.GetAttributeValue("href", ""); } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = "未知"; resultItem.CreateTime = document.DocumentNode.GetInnerText(item.XPath + "/div[1]/table[1]/tr[1]/td[1]"); resultItem.Size = document.DocumentNode.GetInnerText(item.XPath + "/div[1]/table[1]/tr[1]/td[2]"); resultItem.DownloadSpeed = document.DocumentNode.GetInnerText(item.XPath + "/div[1]/table[1]/tr[1]/td[3]"); resultItem.HotLevel = document.DocumentNode.GetInnerText(item.XPath + "/div[1]/table[1]/tr[1]/td[4]"); if (!string.IsNullOrEmpty(resultItem.HotLevel)) { resultItem.HotLevel = System.Web.HttpUtility.HtmlDecode(resultItem.HotLevel); } this.OnResultItemGenerated(resultItem); } catch (Exception) { } } sw.Stop(); } }
public async Task <MagnetSearchResult> SearchAsync(string query, int page, CancellationToken cancellationToken = default) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (page <= 0) { throw new ArgumentOutOfRangeException(nameof(page)); } var url = $"http://www.sobt5.pw/q/{HttpUtility.UrlEncode(query)}.html?sort=rel&page={page}"; var httpClient = _httpClientFactory.CreateClient(); var html = await httpClient.GetStringAsync(url); var context = BrowsingContext.New(); var document = await context.OpenAsync(request => request.Content(html), cancel : cancellationToken); var items = new List <MagnetItem>(); foreach (var element in document.QuerySelectorAll <IHtmlDivElement>("div.search-item")) { var anchor = element.QuerySelector <IHtmlAnchorElement>("div.item-title a"); var strings = anchor.Href.Split('/', '.'); var hash = strings[strings.Length - 2]; var size = element.QuerySelector(".item-bar > span:nth-last-child(2) > b").Text(); var date = element.QuerySelector("div.item-bar b").Text(); var item = new MagnetItem { Name = anchor.Text, Magnet = "magnet:?xt=urn:btih:" + hash, Size = SizeHelper.GetSize(size), Date = DateTime.Parse(date) }; items.Add(item); } var lastPage = 0; var lastPageAnchor = document.QuerySelector <IHtmlAnchorElement>(".pagination > .last_p > a"); if (lastPageAnchor != null) { var queryString = HttpUtility.ParseQueryString(new Uri(lastPageAnchor.Href, UriKind.RelativeOrAbsolute).Query); int.TryParse(queryString["page"], out lastPage); } return(new MagnetSearchResult { Items = items.ToArray(), LastPage = lastPage }); }
public async Task <MagnetSearchResult> SearchAsync(string query, int page, CancellationToken cancellationToken = default) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (page <= 0) { throw new ArgumentOutOfRangeException(nameof(page)); } var url = $"https://www.torrentkitty.app/search/{HttpUtility.UrlEncode(query)}/{page}"; var httpClient = _httpClientFactory.CreateClient(); var html = await httpClient.GetStringAsync(url); var context = BrowsingContext.New(); var document = await context.OpenAsync(request => request.Content(html), cancel : cancellationToken); var items = new List <MagnetItem>(); foreach (var row in document.QuerySelectorAll <IHtmlTableRowElement>("#archiveResult tr:not(:first-child)")) { var name = row.QuerySelector <IHtmlTableDataCellElement>("td.name"); var size = row.QuerySelector <IHtmlTableDataCellElement>("td.size"); var date = row.QuerySelector <IHtmlTableDataCellElement>("td.date"); var magnet = row.QuerySelector <IHtmlAnchorElement>("td.action > a[rel='magnet']"); var item = new MagnetItem { Name = name.Text(), Magnet = magnet.Href, Size = SizeHelper.GetSize(size.Text()), Date = DateTime.Parse(date.Text()) }; items.Add(item); } int lastPage = 0; var pageAnchors = document.QuerySelectorAll <IHtmlAnchorElement>(".pagination > a").ToList(); if (pageAnchors.Any()) { lastPage = pageAnchors.Select(temp => { var text = temp.Text(); int.TryParse(text, out var i); return(i); }).Max(); } return(new MagnetSearchResult() { Items = items.ToArray(), LastPage = lastPage }); }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count == 0) { this.IsFinished = true; } foreach (Match item in itemmatchs) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; string value = item.Value.Replace("\n", "").Replace("\r", "").Replace("&", "&"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(value); if (xmlDoc.HasChildNodes) { XmlNodeList header = xmlDoc.SelectNodes("/li/h3/a"); if (header.Count > 0) { XmlElement element = header[0] as XmlElement; resultItem.Title = element.InnerText; resultItem.DetailUrl = this.WebUrl + element.GetAttribute("href"); } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = "未知"; resultItem.CreateTime = xmlDoc.GetInnerText("/li/dl/dt/span[1]"); resultItem.Size = xmlDoc.GetInnerText("/li/dl/dt/span[2]"); resultItem.HotLevel = xmlDoc.GetInnerText("/li/dl/dt/span[3]"); } this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
public async Task <MagnetSearchResult> SearchAsync(string query, int page, CancellationToken cancellationToken = default) { if (query == null) { throw new ArgumentNullException(nameof(query)); } if (page <= 0) { throw new ArgumentOutOfRangeException(nameof(page)); } var url = $"https://btos.pw/search/{HttpUtility.UrlEncode(query)}/page/{page}"; var httpClient = _httpClientFactory.CreateClient(); httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"); httpClient.DefaultRequestHeaders.Add("accept-language", "zh-CN,zh;q=0.9,ja;q=0.8"); var html = await httpClient.GetStringAsync(url); var context = BrowsingContext.New(); var document = await context.OpenAsync(request => request.Content(html), cancel : cancellationToken); var items = new List <MagnetItem>(); foreach (var row in document.QuerySelectorAll <IHtmlDivElement>("div.data-list > div.row:not(.hidden-xs)")) { var anchor = row.QuerySelector <IHtmlAnchorElement>("a"); var hash = anchor.Href.Split('/').Last(); var size = row.QuerySelector("div.size").Text(); var date = row.QuerySelector("div.date").Text(); var item = new MagnetItem { Name = anchor.Title, Magnet = "magnet:?xt=urn:btih:" + hash, Size = SizeHelper.GetSize(size), Date = DateTime.Parse(date) }; items.Add(item); } var lastPageAnchor = document.QuerySelectorAll <IHtmlAnchorElement>("ul.pagination a[name='numbar']").LastOrDefault(); var lastPage = 0; if (lastPageAnchor != null) { int.TryParse(lastPageAnchor.Href.Split('/').LastOrDefault(), out lastPage); } return(new MagnetSearchResult { Items = items.ToArray(), LastPage = lastPage }); }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); HtmlNode node = document.GetElementbyId("content"); HtmlNode detailnode = node?.SelectSingleNode(node.XPath + "/div[1]/ul[1]"); if (detailnode != null) { item.UpdateTime = detailnode.GetInnerText(detailnode.XPath + "/li[3]/span[1]").Replace("更新时间:", ""); item.HotLevel = detailnode.GetInnerText(detailnode.XPath + "/li[6]/span[1]").Replace("访问热度:", ""); item.MagneticLink = detailnode.GetFirstAttrText(detailnode.XPath + "/li[9]/span[1]/a[1]", "href"); item.ThunderLink = detailnode.GetFirstAttrText(detailnode.XPath + "/li[10]/span[1]/a[1]", "href"); } HtmlNodeCollection filelistnodes = document.GetElementbyId("filelist").ChildNodes; if (filelistnodes != null && filelistnodes.Count > 0) { for (int i = 0; i < filelistnodes.Count; i++) { string source = filelistnodes[i].GetInnerText(filelistnodes[i].XPath + "/span[1]/script[1]").SubStringInner("document.write(decodeURIComponent(", "));").Replace("+", "").Replace("\"", ""); string text = HttpUtility.UrlDecode(source); string size = null; size = filelistnodes[i].GetInnerText(filelistnodes[i].XPath + "/span[2]"); text = text.RemoveEnd(size); item.AddFileItem(new FileItem { Index = i + 1, FileName = text, Size = size }); } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count == 0) { this.IsFinished = true; } foreach (Match item in itemmatchs) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; HtmlDocument document = new HtmlDocument(); document.LoadHtml(item.Value); var head = document.DocumentNode.SelectNodes("/div/a"); if (head != null) { if (head.Count > 0) { HtmlNode first = head[0]; resultItem.Title = HttpUtility.UrlDecode(first.InnerText.Replace("document.write(decodeURIComponent(", "").Replace("));", "").Replace("+", "").Replace("\"", "")).Replace("<fontcolor=\"red\">", "").Replace("</font><fontcolor=\"red\">", "").Replace("</font>", ""); resultItem.DetailUrl = this.WebUrl + HttpUtility.UrlDecode(first.GetAttributeValue("href", "")); } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = "未知"; resultItem.CreateTime = document.DocumentNode.GetInnerText("/div/span[1]/b"); resultItem.Size = document.DocumentNode.GetInnerText("/div/span[2]/b"); resultItem.MagneticLink = document.DocumentNode.GetFirstAttrText("/div/a[2]", "href"); this.OnResultItemGenerated(resultItem); } } catch (Exception) { } } } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); HtmlNode linknode = document.DocumentNode.SelectSingleNode("/html/body/div/div[3]/div[2]/table[1]/tr[5]/td[2]/a"); item.MagneticLink = linknode.GetAttributeValue("href", ""); var filelistnodes = document.DocumentNode.SelectSingleNode("/html/body/div/div[3]/div[2]/table[2]") .ChildNodes .Where( _p => _p.NodeType == HtmlNodeType.Element && _p.Name == "tr" ) .ToList(); if (filelistnodes != null && filelistnodes.Count > 0) { int index = 1; foreach (HtmlNode filenode in filelistnodes) { if (filenode.NodeType == HtmlNodeType.Element) { item.AddFileItem(new FileItem { Index = index++, FileName = filenode.GetInnerText(filenode.XPath + "/td[2]").RemoveStart(" "), Size = filenode.GetInnerText(filenode.XPath + "/td[1]") }); } } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; if (item != null && !string.IsNullOrEmpty(requeststr)) { try { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count > 0) { int first = itemmatchs[0].Value.IndexOf("{"); int last = itemmatchs[0].Value.LastIndexOf(";"); string value = itemmatchs[0].Value.Substring(first, last - first); ContentInfomationWrapper infomationWrapper = JsonConvert.DeserializeObject <ContentInfomationWrapper>(value); if (infomationWrapper != null) { item.UpdateTime = infomationWrapper.information.updated_time; item.HotLevel = infomationWrapper.information.download_count + ""; if (infomationWrapper.information.magnet_file_list != null) { int i = 1; foreach (var fileitem in infomationWrapper.information.magnet_file_list) { item.AddFileItem(new FileItem { Index = i++, FileName = fileitem.name, Size = ((double)fileitem.length / 1024 / 1024 / 1024).ToString("0.00") + " GB" }); } } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(requeststr); HtmlNode listnode = doc.GetElementbyId("content"); var itemnodes = listnode.ChildNodes[1].ChildNodes.Where(_p => _p.NodeType == HtmlNodeType.Element).ToList(); if (itemnodes.Count == 0) { this.IsFinished = true; return; } foreach (HtmlNode itemnode in itemnodes) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; resultItem.Title = itemnode.GetInnerText(itemnode.XPath + "/dt/a"); resultItem.DetailUrl = this.WebUrl + HttpUtility.UrlDecode(itemnode.GetFirstAttrText(itemnode.XPath + "/dt/a", "href"));; if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = itemnode.GetInnerText(itemnode.XPath + "/dt/span"); resultItem.CreateTime = itemnode.GetInnerText(itemnode.XPath + "/dd/span/b"); resultItem.Size = itemnode.GetInnerText(itemnode.XPath + "/dd/span[3]").Replace("文档大小:", ""); resultItem.MagneticLink = itemnode.GetFirstAttrText(itemnode.XPath + "/dd/span[6]/a", "href"); this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(requeststr); HtmlNode listnode = doc.DocumentNode.SelectSingleNode("/html/body/div/div[5]/div[2]"); var itemnodes = listnode.ChildNodes.Where(_p => _p.NodeType == HtmlNodeType.Element && _p.Name == "ul").ToList(); if (itemnodes.Count == 0) { this.IsFinished = true; return; } foreach (HtmlNode itemnode in itemnodes) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; resultItem.Title = itemnode.GetInnerText(itemnode.XPath + "/li[1]/a"); resultItem.DetailUrl = this.WebUrl + HttpUtility.UrlDecode(itemnode.GetFirstAttrText(itemnode.XPath + "/li[1]/a", "href")); if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.CreateTime = itemnode.GetInnerText(itemnode.XPath + "/li[2]/span[3]"); resultItem.Size = itemnode.GetInnerText(itemnode.XPath + "/li[2]/span[1]"); resultItem.HotLevel = itemnode.GetInnerText(itemnode.XPath + "/li[2]/span[4]"); this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); HtmlNode linknode = document.DocumentNode.SelectSingleNode("/html/body/div[2]/div[3]/div/div[1]/div[3]/div[2]/div/a[3]"); //item.MagneticLink = linknode.GetFirstAttrText(linknode.XPath + "/li[9]/span[1]/a[1]", "href"); item.ThunderLink = linknode.GetAttributeValue("href", ""); HtmlNodeCollection filelistnodes = document.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[2]/div[3]/div[1]/div[1]/div[5]/div[2]/ul").ChildNodes; if (filelistnodes != null && filelistnodes.Count > 0) { int index = 1; foreach (HtmlNode filenode in filelistnodes) { if (filenode.NodeType == HtmlNodeType.Element) { string size = filenode.GetInnerText(filenode.XPath + "/span"); item.AddFileItem(new FileItem { Index = index++, FileName = filenode.GetInnerText(filenode.XPath).RemoveEnd(size).RemoveEnd(" "), Size = size }); } } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); var filelistnodes = document.DocumentNode.SelectSingleNode("/html/body/div[2]/div[1]/div/ul[2]/li[5]/div/ol") .ChildNodes .Where( _p => _p.NodeType == HtmlNodeType.Element && _p.Name == "li" ) .ToList(); if (filelistnodes != null && filelistnodes.Count > 0) { int index = 1; foreach (HtmlNode filenode in filelistnodes) { string size = filenode.GetInnerText(filenode.XPath + "/span"); item.AddFileItem(new FileItem { Index = index++, FileName = filenode.GetInnerText(filenode.XPath).RemoveEnd(size), Size = size }); } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { _CiliwangResult content = JsonConvert.DeserializeObject <_CiliwangResult>(requeststr); if (content.status != 200 || content.data.data == null || content.data.data.Count == 0) { this.IsFinished = true; return; } foreach (var item in content.data.data) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; resultItem.Title = item.name; resultItem.DetailUrl = string.Format("https://www.ciliwang.club/source/{0}/detail.html", item.id); if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.CreateTime = item.time; resultItem.Size = item.file_size; resultItem.HotLevel = item.hot + ""; resultItem.MagneticLink = item.uri; this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { _Result content = JsonConvert.DeserializeObject <_Result>(requeststr); if (!content.success || content.data.results == null || content.data.results.Count == 0) { this.IsFinished = true; return; } foreach (var item in content.data.results) { try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; resultItem.Title = item.name; resultItem.DetailUrl = item.detailUrl; resultItem.MagneticLink = item.magnet; resultItem.Size = item.formatSize; resultItem.UpdateTime = item.date; resultItem.HotLevel = item.hot; if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); item.MagneticLink = document.GetElementbyId("MagnetLink")?.InnerText; HtmlNodeCollection filelistnodes = document.DocumentNode.SelectNodes("//table[@class='table table-striped']/tr"); if (filelistnodes != null && filelistnodes.Count > 0) { for (int i = 1; i < filelistnodes.Count; i++) { string text = filelistnodes[i].GetInnerText(filelistnodes[i].XPath + "/td[1]"); string size = filelistnodes[i].GetInnerText(filelistnodes[i].XPath + "/td[2]"); item.AddFileItem(new FileItem { Index = i, FileName = text, Size = size }); } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { item.AddFileItem(new FileItem { FileName = "未知" }); } catch (Exception) { } finally { item.IsDetailLoaded = true; } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); string result = HttpUtility.HtmlDecode(requeststr); if (result.Contains("内部服务器错误:服务器负载过高")) { this.IsFinished = true; } if (!string.IsNullOrEmpty(requeststr)) { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count == 0) { this.IsFinished = true; } foreach (Match item in itemmatchs) { string temp = HttpUtility.HtmlDecode(item.Value); string value = temp; try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(value); if (xmlDoc.HasChildNodes) { XmlNodeList header = xmlDoc.SelectNodes("/dl/dt/a"); if (header.Count > 0) { XmlElement element = header[0] as XmlElement; resultItem.Title = element.InnerText; resultItem.DetailUrl = "http:" + element.GetAttribute("href"); } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = "未知"; resultItem.CreateTime = xmlDoc.GetInnerText("/dl/dd/span[1]/b"); resultItem.Size = xmlDoc.GetInnerText("/dl/dd/span[2]/b"); resultItem.DownloadSpeed = xmlDoc.GetInnerText("/dl/dd/span[4]/b"); resultItem.HotLevel = xmlDoc.GetInnerText("/dl/dd/span[5]/b"); } this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count == 0) { this.IsFinished = true; } foreach (Match item in itemmatchs) { string value = item.Value.Replace("\n", "").Replace("\r", "").Replace("&", "&") + "--></div></div>"; try { MagnetItem resultItem = new MagnetItem() { OwnerWebCrawler = this }; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(value); if (xmlDoc.HasChildNodes) { XmlNodeList header = xmlDoc.SelectNodes("/div/div[1]/h3/a"); if (header.Count > 0) { XmlElement element = header[0] as XmlElement; resultItem.Title = element.InnerText; resultItem.DetailUrl = this.WebUrl + element.GetAttribute("href"); } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } resultItem.ResourceType = xmlDoc.GetInnerText("/div/div[3]/span[1]"); resultItem.CreateTime = xmlDoc.GetInnerText("/div/div[3]/span[2]/b"); resultItem.Size = xmlDoc.GetInnerText("/div/div[3]/span[3]/b"); resultItem.HotLevel = xmlDoc.GetInnerText("/div/div[3]/span[4]/b"); XmlNodeList comm = xmlDoc.SelectNodes("/div/div[3]"); if (comm.Count > 0) { XmlElement element = comm[0] as XmlElement; XmlComment comment = element.LastChild as XmlComment; XmlDocument tempdoc = new XmlDocument(); tempdoc.LoadXml("<TT>" + comment.Value + "</TT>"); resultItem.MagneticLink = tempdoc.GetFirstAttrText("/TT/a[1]", "href"); resultItem.ThunderLink = tempdoc.GetFirstAttrText("/TT/a[2]", "href"); } } this.OnResultItemGenerated(resultItem); } catch (Exception) { } } } //{ // HtmlDocument htmlDocument = new HtmlDocument(); // htmlDocument.LoadHtml(requeststr); // HtmlNodeCollection itemnodes = htmlDocument.DocumentNode.SelectNodes("//div[@class='search-item detail-width']"); // if (itemnodes == null // || itemnodes.Count == 0) // { // this.IsFinished = true; // } // var nodes = itemnodes.Select(_p => HtmlNode.CreateNode(_p.OuterHtml)); // ResultItem resultItem = new ResultItem() // { // OwnerWebCrawler = this // }; // foreach (var itemnode in nodes) // { // HtmlNode head = itemnode.SelectSingleNode("/div[1]/div[1]/h3[1]/a[1]"); // resultItem.Title = head.InnerText; // resultItem.DetailUrl = this.WebUrl + head.GetAttributeValue("href", ""); // resultItem.ResourceType = itemnode.SelectSingleNode("/div[1]/div[3]/span[1]").InnerText; // resultItem.CreateTime = itemnode.SelectSingleNode("/div[1]/div[3]/span[2]/b").InnerText; // resultItem.Size = itemnode.SelectSingleNode("/div[1]/div[3]/span[3]/b").InnerText; // resultItem.HotLevel = itemnode.SelectSingleNode("/div[1]/div[3]/span[4]/b").InnerText; // resultItem.ActiveTime = itemnode.SelectSingleNode("/div[1]/div[3]/span[5]/b").InnerText; // HtmlNode comment = itemnode.SelectSingleNode("/div[1]/div[3]").Element("#comment"); // if (comment != null) // { // comment = HtmlNode.CreateNode("<div>" + comment.OuterHtml.RemoveStart("<!--").RemoveEnd("-->") + "</div>"); // resultItem.MagneticLink = comment.SelectSingleNode("/div[1]/a[1]").GetAttributeValue("href", ""); // resultItem.ThunderLink = comment.SelectSingleNode("/div[1]/a[2]").GetAttributeValue("href", ""); // } // } //} } }
protected override void OnRequestSuccess(object param, string requeststr) { base.OnRequestSuccess(param, requeststr); if (!string.IsNullOrEmpty(requeststr)) { MatchCollection itemmatchs = Regex.Matches(requeststr, this.ItemMatchString, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (itemmatchs.Count > 0) { int first = itemmatchs[0].Value.IndexOf("{"); int last = itemmatchs[0].Value.LastIndexOf(";"); string value = itemmatchs[0].Value.Substring(first, last - first); try { ContentWrapper content = JsonConvert.DeserializeObject <ContentWrapper>(value); if (content != null && content.search != null && content.search.card != null && content.search.card.movie != null) { TitleItem titleItem = new TitleItem { OwnerWebCrawler = this, Title = content.search.card.movie.title, ResourceType = content.search.card.movie.subtype, DetailUrl = "https://www.cilimao.cc/baike/movie/" + content.search.card.movie.encodeId, MovieTitle = content.search.card.movie, }; this.OnTitleItemGenerated(titleItem); } if (content != null && content.search != null && content.search.result != null && content.search.result.content != null && content.search.result.content.Count > 0) { foreach (var item in content.search.result.content) { JObject jobj = item as JObject; if (jobj != null) { ContentItem contentItem = JsonConvert.DeserializeObject <ContentItem>(jobj.ToString()); if (contentItem != null) { ResultItem resultItem = null; if (!string.IsNullOrEmpty(contentItem.shorturl)) { resultItem = new BaiduNetDiskItem { OwnerWebCrawler = this, ResourceType = "未知", Title = contentItem.title, DetailUrl = string.IsNullOrEmpty(contentItem.infohash) ? string.Empty : "https://www.cilimao.cc/information/" + contentItem.infohash, BaiduNetDiskLink = string.IsNullOrEmpty(contentItem.shorturl) ? string.Empty : "https://pan.baidu.com/s/" + contentItem.shorturl, CreateTime = contentItem.created_time, Size = ((double)contentItem.content_size / 1024 / 1024 / 1024).ToString("0.00") + " GB", }; } else { resultItem = new MagnetItem() { OwnerWebCrawler = this, ResourceType = "未知", Title = contentItem.title, DetailUrl = string.IsNullOrEmpty(contentItem.infohash) ? string.Empty : "https://www.cilimao.cc/information/" + contentItem.infohash, MagneticLink = string.IsNullOrEmpty(contentItem.infohash) ? string.Empty : "magnet:?xt=urn:btih:" + contentItem.infohash, CreateTime = contentItem.created_time, Size = ((double)contentItem.content_size / 1024 / 1024 / 1024).ToString("0.00") + " GB", }; } if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam)) { continue; } this.OnResultItemGenerated(resultItem); } } } } else { this.IsFinished = true; } } catch (Exception e) { } } else { this.IsFinished = true; } } }
protected override void OnRequestDetailSuccess(object param, string requeststr) { base.OnRequestDetailSuccess(param, requeststr); MagnetItem item = param as MagnetItem; try { requeststr = HttpUtility.HtmlDecode(requeststr); if (!string.IsNullOrEmpty(requeststr) && item != null) { HtmlDocument document = new HtmlDocument(); document.LoadHtml(requeststr); HtmlNode node = document.DocumentNode.SelectSingleNode("//div[@class='content']"); if (node != null) { item.ActiveTime = node.GetInnerText(node.XPath + "/div[1]/div[1]/p[2]/b[8]"); item.MagneticLink = node.GetFirstAttrText(node.XPath + "/div[1]/div[1]/p[6]/a[1]", "href"); HtmlNodeCollection filelistnodes1 = node.SelectNodes("//div[@class='dd filelist']/p"); HtmlNodeCollection filelistnodes2 = document.GetElementbyId("filelist_hidden").ChildNodes; var filelist = filelistnodes1 == null ? filelistnodes2 == null ? null : filelistnodes2 : filelistnodes2 == null ? filelistnodes1 : filelistnodes1.Concat(filelistnodes2); if (filelist != null && filelist.Any()) { int i = 1; foreach (var filenode in filelist) { string text = filenode.InnerText; string size = null; if (filenode.HasChildNodes) { HtmlNode sizenode = filenode.ChildNodes[2]; if (sizenode != null) { size = sizenode.InnerText; text = text.RemoveEnd(size); } } item.AddFileItem(new FileItem { Index = i++, FileName = text, Size = size }); } } } } } catch (Exception) { } finally { item.IsDetailLoaded = true; } }