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


C# HtmlAgilityPack.HtmlNodeCollection类代码示例

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


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

示例1: LoadHtmlTemplate

        private void LoadHtmlTemplate()
        {
            this.document = new HtmlDocument();
            this.document.Load( Assembly.GetExecutingAssembly().GetManifestResourceStream(HtmlTemplate) );

            this.table = new HtmlNodeCollection(document.GetElementbyId(LogEventTableId));
        }
开发者ID:mk83ko,项目名称:any-log-analyzer,代码行数:7,代码来源:HtmlReportGenerator.cs

示例2: getNameOfEmail

        public static List<string> getNameOfEmail(string url)
        {
            List<string> a = new List<string>();
            HtmlWeb website = new HtmlWeb();
            HtmlAgilityPack.HtmlDocument doc = website.Load(url);
            HtmlNodeCollection authors = new HtmlNodeCollection(doc.DocumentNode.ParentNode); ;
            authors = doc.DocumentNode.SelectNodes(".//li[@itemprop='author']");

            if (!Directory.Exists(@"C:\Springer\"))
            {
                Directory.CreateDirectory(@"C:\Springer\");
            }

            using (StreamWriter outputFile = new StreamWriter(@"C:\Springer\Springer Emails.txt", true))
                {
                    if (authors != null)
                    {

                        foreach (HtmlNode author in authors)
                        {

                            HtmlNode Name = author.SelectSingleNode(".//a[@class='person']");
                            HtmlNode EMail = author.SelectSingleNode(".//a[@class='envelope']");

                            if (EMail != null)
                            {
                                outputFile.WriteLine(Name.InnerText + " - " + EMail.Attributes["title"].Value);
                            }
                        }
                    }

                }

            return a;
        }
开发者ID:Kancho-Baev,项目名称:SpringerBOT,代码行数:35,代码来源:Form1.cs

示例3: Download

 void Download(string url, ref HtmlNodeCollection nodes, ref HtmlNodeCollection nodes2)
 {
     wc.DownloadFile(url, "0.htm");
     doc.Load("0.htm", Encoding.GetEncoding(1251));
     nodes = doc.DocumentNode.SelectNodes("//section[@class != 'promo__write_response']/p");
     nodes2 = doc.DocumentNode.SelectNodes("//div[@class='card__responses__response__information__rating']/*/b");
 }
开发者ID:AlexeyKalina,项目名称:Semantic-Analysis,代码行数:7,代码来源:ParsingWeb.cs

示例4: run

        /// <summary>
        /// Run xpath from html or node
        /// </summary>
        public List<List<KeyValuePair<string, object>>> run(HtmlNode node)
        {
            Factory.Instance.iInfo(string.Format("Running xpathCollection id : {0}", rule.id));

            HtmlNodeCollection nodes = new HtmlNodeCollection(node);
            HtmlNodeCollection n2 = node.SelectNodes(rule.xpath);
            if (n2 != null)
            {
                foreach (HtmlNode n in n2)
                    nodes.Add(n);
            }

            //run
            if (node != null)
            {

                foreach (HtmlNode n in nodes)
                {
                    List<KeyValuePair<string, object>> last_val = null;
                    if (rule.xpathSingle != null)
                    {
                        XPathSingle xs = new XPathSingle(rule.xpathSingle, last_val);
                        last_val = (List<KeyValuePair<string, object>>)xs.Run(n);
                        res.Add(last_val);
                    }
                }
            }
            return res;
        }
开发者ID:kantone,项目名称:intelliscraper,代码行数:32,代码来源:XPathCollection.cs

示例5: ReadNode

		protected Directory ReadNode( HtmlNode directoryNode , HtmlNodeCollection childNodes ) {
			var directory = new Directory {
				Id = Guid.NewGuid().ToString() ,
				Name = directoryNode.InnerText ,
				LastUpdate = RetrieveToDateTime( directoryNode , "" )
			};

			foreach ( var childNode in childNodes ) {
				if ( childNode.Name == "div" ) {
					directory.Directories.Add( ReadNode( childNode.ChildNodes[0] , childNode.ChildNodes[1].ChildNodes ) );
				}

				if ( childNode.Name == "a" ) {
					directory.Bookmarks.Add( new Bookmark {
						Description = childNode.InnerText ,
						Created = RetrieveToDateTime( childNode , "Add_date" ) ,
						Uri = childNode.GetAttributeValue( "href" , string.Empty ) ,
						Icon = childNode.GetAttributeValue( "icon" , string.Empty ) ,
						LastUpdate = RetrieveToDateTime( childNode , "last_modified" ) ,
						IconUrl = childNode.GetAttributeValue( "icon_uri" , string.Empty )
					} );
				}
			}

			return directory;
		}
开发者ID:theuntitled,项目名称:JF.Cloudmarks,代码行数:26,代码来源:NetscapeBookmarkParser.cs

示例6: getListItems

 /// <summary>
 /// 
 /// </summary>
 /// <param name="htmlNodeCollection">moi the tr chua mot item</param>
 /// <returns></returns>
 private List<ItemTemp> getListItems(HtmlNodeCollection htmlNodeCollection,bool isOutBound)
 {
     List<ItemTemp> liItems = null;
     try
     {
         liItems = new List<ItemTemp>();
         int id = 0;
         foreach (HtmlNode node in htmlNodeCollection)
         {
             try
             {
                 ItemTemp item = new ItemTemp();
                 //lay gia
                 HtmlNode nodeTemp = node.SelectSingleNode("td[2]");
                 item.prices = getListprices(nodeTemp);
                 //lay cac segment
                 nodeTemp = node.SelectSingleNode("td[1]");
                 DateTime d=isOutBound?_input.DepartTime:_input.ReturnTime;
                 item.Segments = getListSegments(d,nodeTemp);
                 item.Id = id;
                 //item.TotalTime = node.SelectSingleNode("td[1]//ul/li[3]/strong").InnerText.Replace("Total Duration: ", "");
                 //item.TotalTime = item.TotalTime.Substring(0, item.TotalTime.IndexOf('m') + 1);
                 liItems.Add(item);
                 //chi lay 4 item
                 if (liItems.Count > 3)
                     break;
                 id++;
             }
             catch { }
         }
     }
     catch
     { }
     return liItems;
 }
开发者ID:nvphuong92,项目名称:do-an-tot-nghiep1,代码行数:40,代码来源:AirAsia.cs

示例7: GetDetails

        private static ScorecardDetails GetDetails(HtmlNodeCollection cells, string season)
        {
            string scorecardUrl;
            string homeTeam;
            string awayTeam;
            string groundUrl;
            string groundName;

            DateTime date;
            DateTime.TryParse(cells[1].InnerText.Trim(), out date);

            ParseScorecardLink(cells[4].FirstChild, out scorecardUrl, out homeTeam, out awayTeam);
            if (!IsOfInterest(homeTeam, awayTeam))
                return null;

            ParseGroundLink(cells[5].FirstChild, out groundUrl, out groundName);

            string matchCode = cells[6].InnerText;

            return new ScorecardDetails
                       {
                           Season = season,
                           MatchCode = matchCode,
                           HomeTeam = homeTeam,
                           AwayTeam = awayTeam,
                           GroundName = groundName,
                           GroundUrl = groundUrl,
                           Date = date,
                           LastChecked = DateTime.Now,
                           ScorecardUrl = scorecardUrl,
                           ScorecardAvailable = !string.IsNullOrEmpty(scorecardUrl),
                       };
        }
开发者ID:bugedone,项目名称:somerset,代码行数:33,代码来源:PageCrawler.cs

示例8: ParseIdolData

 private Idol ParseIdolData(HtmlNodeCollection td)
 {
     try
     {
         return new Idol(
         ExtractLabel(td[LabelColumn].InnerText.Trim()), td[NameColumn].InnerText.Trim(), td[RarityColumn].InnerText.Trim().ToRarity(),
         td[CategoryColumn].InnerText.Trim().ToIdolCategory(), Convert.ToInt32(td[LifeColumn].InnerText.Trim()), Convert.ToInt32(td[DanceColumn].InnerText.Trim().Replace(",", "")),
          Convert.ToInt32(td[VocalColumn].InnerText.Trim().Replace(",", "")), Convert.ToInt32(td[VisualColumn].InnerText.Trim().Replace(",", "")),
          DateTime.Parse(td[ImplementationDateColumn].InnerText.Trim()),
         CenterEffect.Create(td[CenterEffectColumn].InnerText.Trim(), 
             td[CenterEffectDetailsColumn].InnerText.Trim()
             .Replace("パッショナイドル", "パッションアイドル")),
         Skill.Create(td[SkillColumn].InnerText.Trim(),
             td[SkillDetailsColumn].InnerText.Trim()
             .Replace("PEFECT", "PERFECT")
             .Replace("PERFCT", "PERFECT")
             .Replace("秒毎", "秒ごと")
             .Replace("秒間", "秒ごと")
             .Replace("しばらく間", "しばらくの間")));
     }
     catch (Exception)
     {
         return null;
     }
 }
开发者ID:noelex,项目名称:Cindeck,代码行数:25,代码来源:GamerChWikiIdolSource.cs

示例9: GetImageUrls

        /// <summary>
        /// Receives a nodeCollection and get all src values in the img nodes of the colection
        /// </summary>
        /// <param name="nodeCollection">NodeCollection</param>
        /// <param name="nodeCollectionName">The name that appears in the log(Generally the target node name)</param>
        /// <param name="expectedSize">The expected size of the return</param>
        /// <returns></returns>
        public List<string> GetImageUrls(HtmlNodeCollection nodeCollection, string nodeCollectionName, int expectedSize)
        {
            List<string> imgUrlsList = new List<string>();

            foreach (var imgUrl in nodeCollection)
            {
                //Get ImagesUrls
                var imgUrls = imgUrl.Descendants("img")
                                    .Select(e => e.GetAttributeValue("src", null))
                                    .Where(s => !String.IsNullOrEmpty(s));

                //Exemplo de 2 wheres
                //.Where(s => s.InnerText == "a")
                //                    .Where(s => s.InnerText ==  "b")                                    
                //                    .Select(e => e.GetAttributeValue("src", null));

                //Create a log if the return number isnot the expected
                if (imgUrls.Count() != expectedSize)
                    LogHandler.createWarningLog(nodeCollectionName, expectedSize, imgUrls.Count());

                //Caso o valor esperado seja maior que um, temos que adicionar todos os itens a lista
                if (expectedSize > 1)
                {
                    foreach (var url in imgUrls)
                    {
                        imgUrlsList.Add(url);
                    }
                }
                //Se o valor esperado for um, adiciona o primeiro da lista
                else
                    imgUrlsList.Add(imgUrls.First());
            }

            return imgUrlsList;
        }
开发者ID:GibranLyra,项目名称:GLyra.Dota2Project,代码行数:42,代码来源:AgilityPackHelper.cs

示例10: ConverArticles

        public List<Article> ConverArticles(HtmlNodeCollection collection)
        {
            foreach (var item in collection)
            {
            }

            return null;
        }
开发者ID:priceLiu,项目名称:parse,代码行数:8,代码来源:YongchHtmlHelper.cs

示例11: ParseTraining

 public List<int> ParseTraining(HtmlNodeCollection calendarTable)
 {
     var trainingIds = calendarTable.Descendants("a")
         .Where(n => n.GetAttributeValue("href", "").Contains("TrainingID="))
         .Select(n => GetTrainingIdFromUrl(n.GetAttributeValue("href", "")))
         .Distinct()
         .ToList();
     return trainingIds;
 }
开发者ID:wezzix,项目名称:funbeat-downloader,代码行数:9,代码来源:TrainingIdParser.cs

示例12: GetLocationInfo

 /// <summary>
 /// Gets the location information such as:
 /// Yükseklik:  28 m. Boylam:  29° 9' D Enlem:  40° 54' K Gün Batımı:  17:10 Gün Doğumu:  07:21
 /// </summary>
 /// <param name="locationInfoNodes">The html location information nodes.</param>
 private static LocationInfo GetLocationInfo(HtmlNodeCollection locationInfoNodes)
 {
     LocationInfo locationInfo = new LocationInfo();
     locationInfo.Altitude = locationInfoNodes[0].LastChild.InnerText.RemoveNbsp();
     locationInfo.Longitude = locationInfoNodes[1].LastChild.InnerText.RemoveNbsp().ReplaceQuoteAndDegree();
     locationInfo.Latitude = locationInfoNodes[2].LastChild.InnerText.RemoveNbsp().ReplaceQuoteAndDegree();
     locationInfo.Sunset = locationInfoNodes[3].LastChild.InnerText.RemoveNbsp();
     locationInfo.Sunrise = locationInfoNodes[4].LastChild.InnerText.RemoveNbsp();
     return locationInfo;
 }
开发者ID:ozcanzaferayan,项目名称:MGM-Weather-Forecast,代码行数:15,代码来源:WeatherParser.cs

示例13: ConvertNodesToSyndicationFeeds

 private static IEnumerable<SyndicationFeedsDataObject> ConvertNodesToSyndicationFeeds(HtmlNodeCollection feeds)
 {
     var query = from link in feeds
                 select new SyndicationFeedsDataObject
                 {
                     FeedUrl = link.Attributes["href"].Value,
                     Title = link.Attributes["title"].Value,
                     MimeType = link.Attributes["type"].Value
                 };
     return query;
 }
开发者ID:rtpHarry,项目名称:HtmlAgilityPackExample-DetectSyndicationFeeds,代码行数:11,代码来源:SyndicationFeedsDataObject.cs

示例14: Translate

		public string Translate (HtmlNodeCollection commandNodes)
		{
			string output = String.Empty;
			
			foreach (HtmlNode node in commandNodes) {
				output += "\t\t\t"; // three tabs should indent the code appropriately
				output += Translate (node);
				output += "\n";
			}
			
			return output;
		}
开发者ID:solilett,项目名称:selenium2csharp,代码行数:12,代码来源:TestCaseCommandTranslator.cs

示例15: AnalyzeNodes

 private void AnalyzeNodes(List<string> addTo, HtmlNodeCollection col2)
 {
     if (col2 != null)
     {
         foreach (HtmlNode node in col2)
         {
             string curNodeData = AnalyzeNode(node);
             if (curNodeData != "") {
                 addTo.Add(curNodeData);
             }
         }
     }
 }
开发者ID:erik-lundgren,项目名称:datacollect,代码行数:13,代码来源:Analyzer.cs


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