Ejemplo n.º 1
0
        protected override void OnRequestDetailSuccess(object param, string requeststr)
        {
            base.OnRequestDetailSuccess(param, requeststr);
            BaiduNetDiskItem item = param as BaiduNetDiskItem;

            try
            {
                if (!string.IsNullOrEmpty(requeststr) &&
                    item != null)
                {
                    HtmlDocument document = new HtmlDocument();
                    document.LoadHtml(requeststr);

                    HtmlNode linknode = document.DocumentNode.SelectSingleNode("//a[@class='red']");

                    if (linknode != null)
                    {
                        string value = linknode.GetAttributeValue("href", "");
                        item.BaiduNetDiskLink = value;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                item.IsDetailLoaded = true;
            }
        }
Ejemplo n.º 2
0
        protected override void OnRequestSuccess(object param, string requeststr)
        {
            base.OnRequestSuccess(param, requeststr);

            if (!string.IsNullOrEmpty(requeststr))
            {
                var obj = JsonConvert.DeserializeAnonymousType(requeststr, new
                {
                    list = new
                    {
                        data = new List <Item>()
                    }
                });

                if (obj != null &&
                    obj.list != null &&
                    obj.list.data != null)
                {
                    foreach (var item in obj.list.data)
                    {
                        BaiduNetDiskItem resultItem = new BaiduNetDiskItem()
                        {
                            OwnerWebCrawler = this
                        };

                        resultItem.Title            = item.title;
                        resultItem.BaiduNetDiskLink = item.link;

                        int i = resultItem.Title.LastIndexOf('.');
                        if (i > 0)
                        {
                            resultItem.ResourceType = resultItem.Title.Substring(i).SubStringUntil(0, ' ');
                        }

                        if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam))
                        {
                            continue;
                        }

                        resultItem.Size       = (item.des + ",").SubStringInner("文件大小:", ",");
                        resultItem.CreateTime = item.des.SubStringInner("分享时间:", ",");

                        this.OnResultItemGenerated(resultItem);
                    }
                }
                else
                {
                    this.IsFinished = true;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnRequestSuccess(object param, string requeststr)
        {
            base.OnRequestSuccess(param, requeststr);

            if (!string.IsNullOrEmpty(requeststr))
            {
                HtmlDocument document = new HtmlDocument();
                document.LoadHtml(requeststr);

                HtmlNode content = document.GetElementbyId("content");

                if (content != null)
                {
                    if (!content.HasChildNodes)
                    {
                        this.IsFinished = true;
                    }

                    foreach (var node in content.ChildNodes)
                    {
                        try
                        {
                            BaiduNetDiskItem resultItem = new BaiduNetDiskItem()
                            {
                                OwnerWebCrawler = this
                            };

                            var title = node.SelectSingleNode(node.XPath + "/h2[1]/a[1]");
                            if (title != null)
                            {
                                resultItem.DetailUrl = this.WebUrl + title.GetAttributeValue("href", "");
                                resultItem.Title     = title.InnerText;

                                int i = resultItem.Title.LastIndexOf('.');
                                if (i > 0)
                                {
                                    resultItem.ResourceType = resultItem.Title.Substring(i).SubStringUntil(0, ' ');
                                }
                            }

                            if (!this.CheckItemNeedCollect(resultItem, param as ItemRequestParam))
                            {
                                continue;
                            }

                            var detail = node.SelectSingleNode(node.XPath + "/div[1]");
                            if (detail != null)
                            {
                                string value = detail.InnerText;
                                resultItem.Size        = value.SubStringInner("文件大小:", ",");
                                resultItem.Author      = value.SubStringInner("分享者:", ",");
                                resultItem.CreateTime  = value.SubStringInner("分享时间:", ",");
                                resultItem.ActiveTimes = value.SubStringInner("浏览次数:", "<");
                            }

                            this.OnResultItemGenerated(resultItem);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        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;
                }
            }
        }