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


C# HtmlNode.QuerySelectorAll方法代码示例

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


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

示例1: ParsePage

        protected override ProductPageInfo ParsePage(HtmlNode document)
        {
            IEnumerable<HtmlNode> metaTags = document.QuerySelectorAll("meta");

            //let if fire a NRE if some element is not found
            string name = document.FindHiddenField("name").GetAttributeValue("value");
            string description = metaTags.First(m => m.GetAttributeValue("property") == "og:description").GetAttributeValue("content");
            string imageUrl = metaTags.First(m => m.GetAttributeValue("property") == "og:image").GetAttributeValue("content");
            string priceText = document.FindHiddenField("price").GetAttributeValue("value");

            return new ProductPageInfo(name, description, Decimal.Parse(priceText, NumberStyles.Currency), imageUrl);
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:12,代码来源:AbercrombieProductPageParser.cs

示例2: LoadTopGames

 public IEnumerable<Game> LoadTopGames(HtmlNode doc)
 {
     var gamesListItem = doc.QuerySelectorAll("ol.GameTiles li");
     foreach (var listItem in gamesListItem)
     {
         var productBox = listItem.QuerySelector("img.ProductBox");
         var title = listItem.QuerySelector("h2 a");
         yield return new Game
         {
             ThumbUrl = productBox.Attributes["src"].Value,
             Title = title.InnerText
         };
     }
 }
开发者ID:scottheckel,项目名称:xbox-indie-game-stats,代码行数:14,代码来源:XboxParser.cs

示例3: ParsePage

        protected override ProductPageInfo ParsePage(HtmlNode document)
        {
            var metaTags = document.QuerySelectorAll("meta");

            //let if fire NRE if some element is not found
            string name = metaTags.First(m => m.GetAttributeValue("name") == "title").GetAttributeValue("content");
            string description = metaTags.First(m => m.GetAttributeValue("name") == "description").GetAttributeValue("content");
            string imageUrl = metaTags.First(m => m.GetAttributeValue("property") == "og:image").GetAttributeValue("content");

            var priceHidden = document.FindHiddenField("ADD_CART_ITEM<>salePriceAmt");

            if (priceHidden == null)
            {
                priceHidden = document.FindHiddenField("ADD_CART_ITEM_ARRAY<>salePriceAmt");
            }

            string priceText = priceHidden.GetAttributeValue("value");

            return new ProductPageInfo(name, description, Decimal.Parse(priceText, NumberStyles.Currency), imageUrl);
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:20,代码来源:KohlsProductPageParser.cs

示例4: ParsePage

        protected override ProductPageInfo ParsePage(HtmlNode document)
        {
            IEnumerable<HtmlNode> metaTags = document.QuerySelectorAll("meta");

            string name = GetValueSomewhereInThePage(document, new[] { "name", "title" }, metaTags);
            string description = GetValueSomewhereInThePage(document, new[] { "description" }, metaTags);
            string priceText = GetValueSomewhereInThePage(document, new[] { "price" }, metaTags);
            string imageUrl = GetValueSomewhereInThePage(document, new[] { "image" }, metaTags);

            if (!String.IsNullOrWhiteSpace(name)
                || !String.IsNullOrWhiteSpace(description)
                || !String.IsNullOrWhiteSpace(priceText)
                || !String.IsNullOrWhiteSpace(imageUrl))
            {
                decimal price = String.IsNullOrWhiteSpace(priceText) ? 0 : Decimal.Parse(priceText, NumberStyles.Currency);
                return new ProductPageInfo(name, description, price, imageUrl);
            }

            return null;
        }
开发者ID:AlexSugak,项目名称:EComWithCQRS,代码行数:20,代码来源:DefaultProductPageParser.cs

示例5: QuerySelectorAll

 /// <summary>
 /// Query selector collection
 /// </summary>
 /// <param name="node">node to query</param>
 /// <param name="query">query string (css selector)</param>
 /// <returns>HtmlNode results</returns>
 protected IEnumerable<HtmlNode> QuerySelectorAll(HtmlNode node, string query)
 {
     return node.QuerySelectorAll(query);
 }
开发者ID:Alchemy86,项目名称:DAS-Desktop,代码行数:10,代码来源:HtmlParser.cs

示例6: BuildTopicData

        /// <summary>
        /// Create organized topic data using HtmlAgilityPack, with Fizzler query
        /// selector extensions.
        /// </summary>
        /// <param name="document"></param>
        /// <param name="initialTopic"></param>
        /// <returns></returns>
        private static Dictionary<string, string> BuildTopicData(HtmlNode document, string initialTopic)
        {
            var topicData = new Dictionary<string, string>();
            string topic = initialTopic.ToLower();
            var textAggregator = new StringBuilder();

            // Get the contents of the main article content node
            var nodes = document.QuerySelectorAll("#mw-content-text").First().ChildNodes;
            foreach (var node in nodes)
            {
                // Header nodes contain headlines, which form subtopic names
                if (node.Name.StartsWith("h"))
                {
                    var headline = node.QuerySelector("span.mw-headline");
                    if (headline == null)
                        continue;

                    // If we have accumulated any text at this point, add it to the last
                    // subtopic and start a new one.
                    if (textAggregator.Length > 0)
                        AddTextData(topicData, topic, textAggregator);

                    textAggregator.Clear();
                    topic = headline.InnerText.ToLower();
                    continue;
                }

                // Paragraph nodes are regular subtopic content
                if (node.Name == "p")
                {
                    // As long as the paragraph contains data, add it to the subtopic.
                    if (textAggregator.Length > 0)
                        textAggregator.Append(" ");
                    textAggregator.Append(node.InnerText);
                }
            }

            AddTextData(topicData, topic, textAggregator);

            return topicData;
        }
开发者ID:carsonmyers,项目名称:Armchair-Intellectual,代码行数:48,代码来源:WikipediaScraper.cs

示例7: SelectItems

 protected IEnumerable<HtmlNode> SelectItems(HtmlNode cq, string css)
 {
     return cq.QuerySelectorAll(css);
 }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:4,代码来源:ScraperBase.cs

示例8: RemoveAttributesWithName

 private static void RemoveAttributesWithName(HtmlNode document, params string[] attributes)
 {
     foreach (var attribute in attributes)
     {
         var elements = document.QuerySelectorAll(string.Format("[{0}]", attribute)).ToList();
         foreach (var element in elements)
         {
             element.Attributes.Remove(attribute);
         }
     }
 }
开发者ID:pmarflee,项目名称:postal,代码行数:11,代码来源:CSSInliner.cs

示例9: GetProductDisadvantages

 private static List<ProductDisadvantage> GetProductDisadvantages(HtmlNode reviewNode)
 {
     return reviewNode.QuerySelectorAll(".cons-cell li").Select(x => new ProductDisadvantage { Feature = WebUtility.HtmlDecode(x.InnerText.Trim()) }).ToList();
 }
开发者ID:Havret,项目名称:CeneoETL,代码行数:4,代码来源:CeneoProductReviewsProvider.cs

示例10: ParseWebPage

        private RealtimeInfo ParseWebPage(HtmlNode document)
        {
            var buses = document.QuerySelectorAll(_searchPath);

            return ConvertHtmlNodeToBuses(buses);
        }
开发者ID:karaaie,项目名称:SLInfo,代码行数:6,代码来源:WebParser.cs


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