当前位置: 首页>>代码示例>>C#>>正文


C# HtmlAgilityPack.Descendants方法代码示例

本文整理汇总了C#中HtmlAgilityPack.Descendants方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlAgilityPack.Descendants方法的具体用法?C# HtmlAgilityPack.Descendants怎么用?C# HtmlAgilityPack.Descendants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack的用法示例。


在下文中一共展示了HtmlAgilityPack.Descendants方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetVacancyUrl

 protected override string GetVacancyUrl(HtmlAgilityPack.HtmlNode div)
 {
     var vacancyHref = div.Descendants("a").Where(
         d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("vacancy-title"))
         .Select(d => d.Attributes["href"].Value).SingleOrDefault();
     return BaseUrl + vacancyHref;
 }
开发者ID:ericojonathan,项目名称:tdd.demand,代码行数:7,代码来源:RabotaUaCrawler.cs

示例2: GetPosition

 protected override string GetPosition(HtmlAgilityPack.HtmlNode div)
 {
     return div.Descendants("a").Where(
        d => d.Attributes.Contains("class") &&
        d.Attributes["class"].Value.Contains("rua-b-vacancy-title") || d.Attributes["class"].Value.Contains("jqKeywordHighlight")
        ).Select(d => d.InnerText).First();
 }
开发者ID:ericojonathan,项目名称:tdd.demand,代码行数:7,代码来源:RabotaUaCrawler.cs

示例3: GetNode

        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        /// <param name="attribute"></param>
        /// <param name="valuePortion"></param>
        /// <returns></returns>
        public static HtmlAgilityPack.HtmlNode GetNode(HtmlAgilityPack.HtmlNode node,
                                            string element,
                                            string attribute,
                                            string valuePortion,
                                            bool tryNull = false)
        {
            if(tryNull)
            {
                try
                {
                    var _nodes = node.Descendants(element)
                            .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));

                    if(_nodes != null && _nodes.Count() > 0)
                    {
                        var _node = _nodes.ToArray()[0];//.SingleOrDefault();
                        return _node;
                    }
                }
                catch { }
            }
            else
            {
                var _nodes = node.Descendants(element)
                            .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));

                if(_nodes != null && _nodes.Count() > 0)
                {
                    var _node = _nodes.ToArray()[0];//.SingleOrDefault();
                    return _node;
                }
            }
            return null;
        }
开发者ID:jcmangubat,项目名称:YPS.Engine,代码行数:42,代码来源:HtmlUtil.cs

示例4: GetInnerText

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="element"></param>
 /// <param name="attribute"></param>
 /// <param name="valuePortion"></param>
 /// <returns></returns>
 public static string GetInnerText(HtmlAgilityPack.HtmlNode node,
                                     string element,
                                     string attribute,
                                     string valuePortion,
                                     string defaultValue = "")
 {
     var _node = node.Descendants(element)
                 .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion))
                 .FirstOrDefault();
     if(_node == null)
         return defaultValue;
     return _node.InnerText;
 }
开发者ID:jcmangubat,项目名称:YPS.Engine,代码行数:21,代码来源:HtmlUtil.cs

示例5: GetItemNodes

 private IEnumerable<HtmlAgilityPack.HtmlNode> GetItemNodes(HtmlAgilityPack.HtmlNode node)
 {
     var itemscopeAttr = node.GetAttributeItemScope();
     if (itemscopeAttr != null)
     {
         yield return node;
         yield break;
     }
     foreach (var childNode in node.Descendants())
     {
         foreach (var item in GetItemNodes(childNode))
         {
             yield return item;
         }
     }
 }
开发者ID:joshcodes,项目名称:JoshCodes.Web,代码行数:16,代码来源:Parser.cs

示例6: GetVacancyUrl

 protected override string GetVacancyUrl(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(1).Descendants("a").Single().Attributes["href"].Value;
 }
开发者ID:ericojonathan,项目名称:tdd.demand,代码行数:4,代码来源:PrgJobsComCrawler.cs

示例7: GetPosition

 protected override string GetPosition(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(1).Descendants("a").Single().InnerText;
 }
开发者ID:ericojonathan,项目名称:tdd.demand,代码行数:4,代码来源:PrgJobsComCrawler.cs

示例8: GetCompany

 protected override string GetCompany(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("td").ElementAt(2).Descendants("em").Single().InnerText;
 }
开发者ID:pparadis,项目名称:TddDemand,代码行数:4,代码来源:PrgJobsComCrawler.cs

示例9: GetPosition

 protected override string GetPosition(HtmlAgilityPack.HtmlNode row)
 {
     return row.Descendants("a").Where(
         r => r.Attributes.Contains("class") && r.Attributes["class"].Value.Contains("title"))
         .Select(r => r.InnerText).SingleOrDefault();
 }
开发者ID:ericojonathan,项目名称:tdd.demand,代码行数:6,代码来源:CareersStackoverfowComCrawler.cs

示例10: VideosForCategory

        private List<VideoInfo> VideosForCategory(HtmlAgilityPack.HtmlNode node)
        {
            List<VideoInfo> videoList = new List<VideoInfo>();

            var sections = node.Descendants("section").Where(s => s.GetAttributeValue("class", "") == "tv");
            if (sections != null)
            {
                foreach (var section in sections)
                {
                    var a = section.SelectSingleNode("a");
                    if (a != null)
                    {
                        VideoInfo video = new VideoInfo();
                        video.VideoUrl = baseUrl + a.GetAttributeValue("href", "");
                        var img = a.Descendants("img");
                        if (img != null && img.First() != null)
                        {
                            video.Thumb = img.First().GetAttributeValue("src", "");
                            video.Title = img.First().GetAttributeValue("alt", "");
                        }
                        var dd = a.Descendants("dd");
                        if (dd != null && dd.FirstOrDefault() != null)
                            video.Length = dd.FirstOrDefault().InnerText;
                        var h1 = a.Descendants("h1");
                        var descP = section.Descendants("p").Where(p => p.GetAttributeValue("class", "") == "ellipsis-lastline");
                        if (descP != null && descP.FirstOrDefault() != null)
                            video.Description = descP.FirstOrDefault().InnerText;
                        if (EnableAOSearch)
                        {
                            SerializableDictionary<string, string> other = new SerializableDictionary<string, string>();
                            var ul = section.SelectSingleNode("div[@class = 'details']/ul[@class = 'keywords']");
                            if (ul != null)
                            {
                                IEnumerable<HtmlNode> keyAs = ul.Descendants("a");
                                foreach (HtmlNode keyA in keyAs)
                                {
                                    other.Add(keyA.GetAttributeValue("data-keyword", ""), keyA.GetAttributeValue("href", ""));
                                }
                            }
                            video.Other = other;
                        }
                        videoList.Add(video);
                    }
                }
            }
            return videoList;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:47,代码来源:URPlayUtil.cs

示例11: GetCompany

 protected override string GetCompany(HtmlAgilityPack.HtmlNode div)
 {
     return div.Descendants("div").Where(
         d => d.Attributes.Contains("class") &&
         d.Attributes["class"].Value.Contains("companyName")).Select(d => d.FirstChild.InnerText).First();
 }
开发者ID:pparadis,项目名称:TddDemand,代码行数:6,代码来源:RabotaUaCrawler.cs

示例12: GetVacancyHref

 private static string GetVacancyHref(HtmlAgilityPack.HtmlNode div)
 {
     var vacancyHref = div.Descendants("a").Where(
         d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("vacancyDescription"))
         .Select(d => d.Attributes["href"].Value).SingleOrDefault();
     return vacancyHref;
 }
开发者ID:pparadis,项目名称:TddDemand,代码行数:7,代码来源:RabotaUaCrawler.cs

示例13: RemoveUnwantedTags

 private void RemoveUnwantedTags(ConfigSection config, HtmlAgilityPack.HtmlNode parentNode)
 {
     if (parentNode != null && config != null && config.RemoveTags != null && config.RemoveTags.Count > 0)
     {
         parentNode.Descendants()
                 .Where(n => config.RemoveTags.Contains(n.Name.ToLowerInvariant()))
                 .ToList()
                 .ForEach(n => n.Remove());
     }
 }
开发者ID:Microsoft,项目名称:openscraping-lib-csharp,代码行数:10,代码来源:StructuredDataExtractor.cs

示例14: GetNodeCollection

 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="element"></param>
 /// <param name="attribute"></param>
 /// <param name="valuePortion"></param>
 /// <returns></returns>
 public static IEnumerable<HtmlAgilityPack.HtmlNode> GetNodeCollection(HtmlAgilityPack.HtmlNode node,
                                     string element,
                                     string attribute,
                                     string valuePortion)
 {
     var _nodes = node.Descendants(element)
                 .Where(d => d.Attributes.Contains(attribute) && d.Attributes[attribute].Value.Contains(valuePortion));
     return _nodes;
 }
开发者ID:jcmangubat,项目名称:YPS.Engine,代码行数:17,代码来源:HtmlUtil.cs

示例15: SetRequestFormInfo

        private static NewThreadRequest SetRequestFormInfo(HtmlAgilityPack.HtmlNode root)
        {
            NewThreadRequest data = new NewThreadRequest();
            var formNodes = root.Descendants("input").ToArray();

            var formKeyNode = formNodes
                .Where(node => node.GetAttributeValue("name", "").Equals(THREAD_FORMKEY_KEY))
                .FirstOrDefault();

            var formCookieNode = formNodes
                .Where(node => node.GetAttributeValue("name", "").Equals(THREAD_FORMCOOKIE_KEY))
                .FirstOrDefault();

            try
            {
                data.FormKey = formKeyNode.GetAttributeValue("value", "");
                data.FormCookie = formCookieNode.GetAttributeValue("value", "");
            }
            catch (Exception)
            {
                throw new InvalidOperationException("Could not parse newReply form data.");
            }

            return data;
        }
开发者ID:jarkkom,项目名称:awfuldotnet,代码行数:25,代码来源:NewThreadRequest.cs


注:本文中的HtmlAgilityPack.Descendants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。