• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# HtmlAgilityPack.HtmlNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ActionUrlNode

 public ActionUrlNode(HtmlNode htmlNode)
     : base(htmlNode.NodeType, htmlNode.OwnerDocument, -1)
   {
       Name = htmlNode.Name;
       CopyFrom(htmlNode, false);
       RouteValues = new Dictionary<string, RouteValueDictionary>();
   }
开发者ID:TheJayMann,项目名称:RazorGenerator,代码行数:7,代码来源:ActionUrlNode.cs


示例17: ParseLink

        public HtmlNode ParseLink(HtmlNode node)
        {
            HtmlNode htmlHref = null;
            htmlHref = node.SelectSingleNode("a");

            return htmlHref;
        }
开发者ID:Soucre,项目名称:Working_git_vfs,代码行数:7,代码来源:FeedStoxDocument.cs


示例18: ParseChapterRow

        private void ParseChapterRow(HtmlNode tr)
        {
            var item = new Book();

            var chaperTd = HtmlParseHelper.GetSingleDirectChildByType(tr, "td");
            var chaperUrl = HtmlParseHelper.GetSingleDirectChildByType(chaperTd, "a");
            var websiteTd = HtmlParseHelper.GetSingleDirectChildByTypeAndIndex(tr, "td", 1);
            var websiteName = HtmlParseHelper.GetSingleDirectChildByType(websiteTd, "a");
            var websiteIndexTd = HtmlParseHelper.GetSingleDirectChildByTypeAndIndex(tr, "td", 2);
            var websiteIndexUrl = HtmlParseHelper.GetSingleDirectChildByType(websiteIndexTd, "a");

            item.LastUpdateTime = DateTime.Now;


            item.Name = metaData.Name.Trim();
            item.IndexPage = new Uri("http://www.xiaoelang.com" + websiteIndexUrl.Attributes["href"].Value, UriKind.Absolute);
            item.LastestUpdateChapterName = chaperUrl.InnerText.Trim();
            item.WebSite = new WebSite();
            item.WebSite.WebSiteName = websiteName.InnerText.Trim();

            if (item.WebSite.WebSiteName.Contains(websiteFilter1) || item.WebSite.WebSiteName.Contains(websiteFilter2))
                return;

            var websiteBookPairAlreadyExists = (from i in items
                                                where i.WebSite.WebSiteName == item.WebSite.WebSiteName
                                                select i).FirstOrDefault();

            if (websiteBookPairAlreadyExists == null)
            {
                items.Add(item);
            }
        }
开发者ID:gracepig,项目名称:SmartReader,代码行数:32,代码来源:XiaoelangBookLastestUpdatePageParser.cs


示例19: ExtractActivity

        private static Activity ExtractActivity(HtmlNode node, int index)
        {
            var name = node.Descendants("div")
                           .Where(div => div.GetAttributeValue("class", null) == "action_prompt")
                           .Select(div => HtmlEntity.DeEntitize(div.InnerText).Trim().Replace("  ", " "))
                           .FirstOrDefault();
            if (name == null)
            {
                throw new InvalidDataException("Unable to find activity name");
            }

            return new Activity
                {
                    Sequence = index,
                    Name = name,
                    Note = node.Descendants("li")
                               .Where(li => li.GetAttributeValue("class", null) == "stream_note")
                               .Select(li => HtmlEntity.DeEntitize(li.InnerText).Trim())
                               .FirstOrDefault(),
                    Sets = node.Descendants("li")
                               .Where(li => li.GetAttributeValue("class", null) != "stream_note")
                               .Select(ExtractSet)
                               .ToList()
                };
        }
开发者ID:NathanBaulch,项目名称:FitBot,代码行数:25,代码来源:ScrapingService.cs


示例20: YoutubeVideoEntry

        public YoutubeVideoEntry(HtmlNode node)
        {
            var url_node = node.SelectNodes(".//a[@href]");

            if (url_node != null)
            {
                var url_value = url_node.FirstOrDefault().Attributes["href"].Value;
                var splitIndex = url_value.IndexOf("&");

                if (splitIndex > 0)
                {
                    url = "http://www.youtube.com" + url_value.Substring(0, splitIndex);
                }
            }

            var title_node = node.SelectNodes(".//span[contains(@class, 'video-title')]");

            if (title_node != null)
                title = title_node.FirstOrDefault().InnerText;

            if (!String.IsNullOrEmpty(title))
                title = title.Trim();

            var img_node = node.SelectNodes(".//img[@src]");

            if (img_node != null)
                imageUrl = "http:" + img_node.FirstOrDefault().Attributes["src"].Value;
        }
开发者ID:KarimLUCCIN,项目名称:YoutubePlaylistDownloader,代码行数:28,代码来源:YoutubeVideoEntry.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HtmlAgilityPack.HtmlNodeCollection类代码示例发布时间:2022-05-26
下一篇:
C# HtmlAgilityPack.HtmlDocument类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap