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


C# HtmlAgilityPack.HtmlNode类代码示例

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


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

示例1: ConvertContentTo

 private static void ConvertContentTo(HtmlNode node, TextWriter outText)
 {
     foreach (HtmlNode subnode in node.ChildNodes)
       {
     ConvertTo(subnode, outText);
       }
 }
开发者ID:alexeib,项目名称:ReadSharp,代码行数:7,代码来源:HtmlUtilities.cs

示例2: SanitizerNodeVisited

        void SanitizerNodeVisited(string nodeName, HtmlNode node, XmlWriter writer)
        {
            if (nodeName == "img" && node.Attributes["src"] != null && node.Attributes["src"].Value.StartsWith("cid:"))
            {
                // split src
                var src = node.Attributes["src"].Value.Split(new[] { ':' }, 2);

                if (src.Length == 2)
                {
                    // Find inline attachment with given contentid
                    var document = source.Documents.FirstOrDefault(d => d.ContentType == ContentType.Inline && d.ContentId == src[1]);

                    if (document != null)
                    {
                        // Replace content-id url with filename
                        var filename = ClientState.Current.Storage.ResolvePhysicalFilename(".", document.StreamName);

                        node.Attributes["src"].Value = String.Format("file://{0}", filename);
                    }
                }
            }
            else if (nodeName == "a" && node.Attributes["href"] != null)
            {
                var url = node.Attributes["href"].Value;

                // Clean href and inject javascript hook
                node.Attributes["href"].Value = String.Empty;

                writer.WriteAttributeString("onclick", String.Format("javascript:window.external.JsNavigate('{0}')", url));
            }
        }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:31,代码来源:MessageBuilder.cs

示例3: ParseResult

        private Result ParseResult(HtmlNode resultSet)
        {
            string[] courseSplit = _currentCourse.Split(new[] { "<br>" }, StringSplitOptions.RemoveEmptyEntries);
            string courseName = courseSplit[0];
            string eventName = courseSplit[1];

            var doc = new HtmlDocument();
            doc.LoadHtml(resultSet.OuterHtml);

            IEnumerable<HtmlNode> allResults = doc.DocumentNode.QuerySelectorAll("td");
            string position = allResults.ElementAt(0).QuerySelector("b").InnerText;
            string name = allResults.ElementAt(1).QuerySelector("b").InnerText;
            string jockey = allResults.ElementAt(2).QuerySelector("b").InnerText;
            string startingPrice = allResults.ElementAt(3).QuerySelector("b").InnerText.Trim();

            var price = new Price{DecimalPrice = 0,Denominator=0,Numerator = 0};
            try {
                price = new Price(startingPrice);
            } catch(ArgumentException) {}

            return new Result
                   	{
                        CourseName = courseName,
                        EventName = eventName,
                        Position = position,
                        HorseName = name,
                        JockeyName = jockey,
                        StartingPriceDecimal = price.DecimalPrice,
                        StartingPriceDenominator = price.Denominator,
                        StartingPriceNumerator = price.Numerator
                    };
        }
开发者ID:gregsochanik,项目名称:html-reader,代码行数:32,代码来源:BritishHorseRacingWebReaderTest.cs

示例4: AddPackage

        private static void AddPackage(SteamApp app, HtmlNode packageNode)
        {
            var package = app.AddNewPackage();

            var packageTitleNode = packageNode.SelectSingleNode($"//{PackageTitle}");

            package.Title = packageTitleNode.InnerHtml.Replace("Buy ", "").Trim();

            var priceNodes = packageNode.SelectNodes($"//div[@class='{PackagePriceXPath}']");

            if (priceNodes != null)
            {
                var priceNode = priceNodes[0];

                package.CurrentPrice = ParseNodeWithCurrencyToDecimal(priceNode);

                package.OriginalPrice = package.CurrentPrice;
            }
            else
            {
                var originalPriceNode = packageNode.SelectSingleNode($"//div[@class='{PackageOriginalPriceXPath}']");

                package.OriginalPrice = ParseNodeWithCurrencyToDecimal(originalPriceNode);

                var discountPriceNode = packageNode.SelectSingleNode($"//div[@class='{PackageDiscountPriceXPath}']");

                package.CurrentPrice = ParseNodeWithCurrencyToDecimal(discountPriceNode);
            }
        }
开发者ID:tstepanski,项目名称:SteamScraper,代码行数:29,代码来源:Parser.cs

示例5: NavigateToSubstitutionTableAndRemoveTextNodex

 private HtmlNodeCollection NavigateToSubstitutionTableAndRemoveTextNodex (HtmlNode root)
 {
     HtmlNode vp = root.LastChild.PreviousSibling;
     HtmlNode haupt = vp.ChildNodes[5];
     HtmlNodeCollection collectionWithoutTextNodes = removeTextNodes(haupt.ChildNodes);
     return collectionWithoutTextNodes;
 }
开发者ID:Flogex,项目名称:Vertretungsplan,代码行数:7,代码来源:LoadSubstitutionSchedulesFromWeb.cs

示例6: ProcessContent

 private static void ProcessContent(HtmlNode node, TextWriter outText)
 {
     foreach (var child in node.ChildNodes)
     {
         ProcessNode(child, outText);
     }
 }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:7,代码来源:Html2TextConverter.cs

示例7: TagOpenToken

 public TagOpenToken(int id, HtmlNode node, TextVisualProperties properties, int parentID)
     : base(id)
 {
     Name = node.Name;
     TextProperties = properties;
     ParentID = parentID;
 }
开发者ID:bdvsoft,项目名称:reader_wp8_OPDS,代码行数:7,代码来源:TagOpenToken.cs

示例8: OnScrape

 protected override string OnScrape(string url, HtmlNode elem)
 {
     url = SubstringBetween(elem.InnerHtml, "un=\"", "\"");
     if (!url.StartsWith("http"))
         url = "http://" + url;
     return new Uri(url).AbsoluteUri;
 }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:7,代码来源:Dwn.cs

示例9: CreateSchedule_WFromNode

        // Schedule_W 얻기
        private Schedule_W CreateSchedule_WFromNode(HtmlNode node, Int32 year, Int32 month, Int32 day)
        {
            try
            {
                if (GetInnerHtml(node, "none") != null || GetInnerHtml(node, "relay") == null)
                {
                    return null;
                }

                return new Schedule_W
                {
                    Year = year,
                    Month = month,
                    Day = day,
                    Time = GetInnerHtml(node, "time"),
                    Play = GetInnerHtml(node, "play"),
                    Relay = GetInnerHtml(node, "relay"),
                    BallPark = GetInnerHtml(node, "ballpark"),
                    Etc = GetInnerHtml(node, "etc"),
                };
            }
            catch (Exception exception)
            {
                throw exception;
            }

        }
开发者ID:Puppetplay,项目名称:BeThe2016,代码行数:28,代码来源:ParserSchedule.cs

示例10: BuildMarketRate

        private MarketRateModel BuildMarketRate(HtmlNode monthNode)
        {
            var result = new MarketRateModel();
            string value = "";
            var dataCode = monthNode.GetAttributeValue("href", "http://finance.ifeng.com/app/hq/stock/sh000001/");
            if ("http://finance.ifeng.com/app/hq/stock/sh000001/" == dataCode)
            {
                value = monthNode.NextSibling.NextSibling.InnerText.Trim();
                value = value.Split(' ')[0];
                result.Type = RateType.StockShangzheng;
                result.Rate = decimal.Parse(value);
            }
            else if ("http://finance.ifeng.com/app/hq/stock/sz399001/" == dataCode)
            {
                value = monthNode.NextSibling.NextSibling.InnerText.Trim();
                value = value.Split(' ')[0];
                result.Type = RateType.StockShenzhen;
                result.Rate = decimal.Parse(value);
            }
            else
            {
                return null;
            }

            result.CreateTime = DateTime.Now;
            result.RateDay = DateTime.Now.Date;
            result.Source = SourceType.eIfeng;

            return result;
        }
开发者ID:bestlimao,项目名称:mao,代码行数:30,代码来源:StockIfengProvider.cs

示例11: ParseArticleInfoDiv

        private static ArticleInfo ParseArticleInfoDiv(HtmlNode articleDiv)
        {
            var linkToArticle = articleDiv.SelectSingleNode("h3/a");
            var dateDiv = articleDiv.SelectSingleNode("div[@class='headline-date']");
            var commentCountNode = articleDiv.SelectSingleNode("h3/a[@class='commentCount']");

            var articleInfo = new ArticleInfo();

            articleInfo.Url = linkToArticle.Attributes["href"].Value;
            if (articleInfo.Url.Contains(@"/video/"))
            {
                throw new CommonParsingException("Delfi TV article");
            }

            articleInfo.Id.ExternalId = articleInfo.Url.GetQueryParameterValueFromUrl("id");
            articleInfo.Title = linkToArticle.InnerText;
            articleInfo.DatePublished = DelfiWordyDateParser.Parse(dateDiv.InnerText);
            articleInfo.DateScraped = DateTime.UtcNow.AddHours(2);
            articleInfo.Id.Portal = Portal.Delfi;
            articleInfo.CommentCount = commentCountNode == null ? 0 : Convert.ToInt32(commentCountNode.InnerText.TrimStart('(').TrimEnd(')'));

            var articleId = Convert.ToInt32(articleInfo.Url.GetQueryParameterValueFromUrl("id"));
            if (articleId == 0) throw new CommonParsingException("Article id not found");

            return articleInfo;
        }
开发者ID:jonas-paul,项目名称:portal-scrape,代码行数:26,代码来源:DelfiArticleInfoScraper.cs

示例12: GetListNodeToTag

 public static List<HtmlNode> GetListNodeToTag(HtmlNode node, string tag,string att, bool remove_text = false)
 {
     // for vao chirdNode
     node = node.ChildNodes.Where(t => t.GetAttributeValue(tag, "") == att).ToList()[0];
     //end
     return GetListNode(node, remove_text);
 }
开发者ID:a5wap123,项目名称:DemoDll_F,代码行数:7,代码来源:Getnode.cs

示例13: Field

 public Field(HtmlNode node)
 {
     String fieldInnerText = Utils.RemoveAllNotNumberCharacters(node.InnerText);
     String[] tempArray = fieldInnerText.Split(',');
     this.actual = int.Parse(tempArray[0]);
     this.max = int.Parse(tempArray[1]);
 }
开发者ID:wrobeseb,项目名称:parRobot,代码行数:7,代码来源:Field.cs

示例14: GetTable1Node

        private HtmlNode GetTable1Node(HtmlNode node)
        {
            HtmlNode table = UIUtils.CreateReportTableNode(node);

            UIUtils.AddColumnRowToTable(table,
                                           "Total Number of Patients",
                                            highrisk.denominator.ToString("#,###,###"),"");

            int percent = (int)Math.Round(100 * (double)high_risk_prevelance / (double)highrisk.denominator, 0);

            UIUtils.AddColumnRowToTable(table,
                                           "All High Risk BRCA Patients",
                                            high_risk_incidence.ToString("#,###,###"),
                                            percent.ToString() + "%");

            percent = (int)Math.Round(100 * (double)high_risk_prevelance / (double)highrisk.denominator, 0);

            UIUtils.AddColumnRowToTable(table,
                                           "New High Risk BRCA",
                                            high_risk_incidence.ToString("#,###,###"),
                                            percent.ToString() + "%");

            percent = (int)Math.Round(100 * (double)high_risk_seenInRC / (double)highrisk.denominator, 0);

            UIUtils.AddColumnRowToTable(table,
                                           "All High Risk BRCA Seen In Cancer Genetics",
                                            high_risk_seenInRC.ToString("#,###,###"),
                                            percent.ToString() + "%");
            return table;
        }
开发者ID:mahitosh,项目名称:HRA4,代码行数:30,代码来源:BrcaRiskElement.cs

示例15: ExtractTitles

 private static IEnumerable<string> ExtractTitles(HtmlNode container)
 {
     // <a href="http://fr.feedbooks.com/item/316137/les-les-de-l-espace" itemprop="url">Les Îles de l'espace</a>
     return from element in container.Descendants("a")
            where element.GetAttributeValue("href", "").StartsWith("http://fr.feedbooks.com/item/")
            select element.InnerText;
 }
开发者ID:mareek,项目名称:WebAdHocCrawler,代码行数:7,代码来源:FeedBookHelper.cs


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