本文整理汇总了C#中HtmlAgilityPack.HtmlNodeCollection.Count方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNodeCollection.Count方法的具体用法?C# HtmlNodeCollection.Count怎么用?C# HtmlNodeCollection.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNodeCollection
的用法示例。
在下文中一共展示了HtmlNodeCollection.Count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetFinancialRatios
private void SetFinancialRatios( HtmlNodeCollection nodes )
{
if ( nodes == null || nodes.Count( ) == 0 ) return;
// First Column contains ([] represents index in array):
// Range[0], 52Week[1], Open[2], Vol/Avg[3], Market Cap[4], P/E[5]
string [] firstCol = nodes [ 0 ].ChildNodes.Where( i => i.InnerText != "\n" )
.Select( ( i ) => i.InnerText ).ToArray<string>( ).Select( i => i.Replace( "\n", " " )
.Substring( 1, i.Length - 1 ) ).ToArray<string>( );
var range = ParseRange( firstCol [ 0 ] );
RangeLow = range [ 0 ];
RangeHigh = range [ 1 ];
var _52Week = Parse52Week( firstCol [ 1 ] );
FiftyTwoWeekLow = _52Week [ 0 ];
FiftyTwoWeekHigh = _52Week [ 1 ];
Open = ParseOpen( firstCol [ 2 ] ) != null ? Convert.ToDouble( ParseOpen( firstCol [ 2 ] ) ) : 0;
var vol = ParseVolume( firstCol [ 3 ] );
VolumeAverage = vol [ 0 ];
VolumeTotal = vol [ 1 ];
MarketCap = ParseMarketCap( firstCol [ 4 ] );
PriceEarnings = ParsePriceEarnings( firstCol [ 5 ] );
// Second Column contains ([] represents index in array):
// Div/Yield[0], EPS[1], Shares[2], Beta[3], Instituional Ownership[4]
string [] secondCol = nodes [ 1 ].ChildNodes.Where( i => i.InnerText != "\n" )
.Select( i => i.InnerText ).ToArray<string>( )
.Select( i => i.Replace( "\n", " " ) ).ToArray<string>( );
var divs = ParseDividend( secondCol [ 0 ] );
Dividend = divs != null ? divs [ 0 ] : null;
DividendYield = divs != null ? divs [ 1 ] : null;
EarningsPerShare = ParseEarningsPerShare( secondCol [ 1 ] );
if ( secondCol.Length >= 4 )
{
Shares = ParseShares( secondCol [ 2 ] );
Beta = ParseBeta( secondCol [ 3 ] );
InstitutionalOwnership = ParseInstituionalOwnership( secondCol [ 4 ] );
}
else
{
// TODO: Implement sparse information case here!
}
}
示例2: SetRelatedPersons
private void SetRelatedPersons( HtmlNodeCollection nodes )
{
var baseQ = nodes [ nodes.Count( ) - 1 ].SelectSingleNode( ".//table[contains(@class, 'id-mgmt-table')]" );
if ( baseQ == null ) return;
OfficersAndDirectors = new List<ImportantPerson>( );
var ppl = nodes [ nodes.Count( ) - 1 ].SelectSingleNode( ".//table[contains(@class, 'id-mgmt-table')]" )
.SelectNodes( ".//tr//td[contains(@class, 'p ')]" ).Select( i => i.InnerText.Replace( "\n\n", ": " )
.Replace( "\n", "" ) ).ToArray<string>( );
foreach ( string person in ppl )
{
var b = person.Split( ':' );
OfficersAndDirectors.Add( new ImportantPerson { Name = b [ 0 ], Role = b [ 1 ].Substring( 1 ) } );
}
}
示例3: SetSectorsAndIndustries
private void SetSectorsAndIndustries( HtmlNodeCollection nodes )
{
if ( nodes.Count( ) < 8 ) return;
var externalLinks = nodes [ 5 ].ChildNodes.Select( i => new { i.InnerText, i.InnerHtml } );
var sectorAndIndustry = nodes [ 6 ].ChildNodes.Where( i => i.InnerText != "\n" ).Select( i => i.InnerText ).ToArray<string>( );
int sectorIndex = sectorAndIndustry [ 0 ].IndexOf( "Sector:" ) + 7;
int sectorIndexEnd = sectorAndIndustry [ 0 ].IndexOf( " >" );
if ( sectorIndexEnd == -1 ) return;
int industryIndex = sectorAndIndustry [ 0 ].IndexOf( "Industry:" ) + 9;
int endingMark = sectorAndIndustry [ 0 ].IndexOf( "\n\n" ) + 9;
Sector = sectorAndIndustry [ 0 ].Substring( sectorIndex + 1, sectorIndexEnd - sectorIndex - 1 ).Replace( "&", "&" );
Industry = sectorAndIndustry [ 0 ].Substring( industryIndex + 1, endingMark - industryIndex - 10 ).Replace( "&", "&" );
Description = nodes [ 7 ].ChildNodes.Where( i => i.InnerText != "\n" ).Select( i => i.InnerText ).ToArray<string>( ) [ 0 ].Replace( "More from Reuters »", "" ).Replace( "\n", "" );
}
示例4: FilterPage
protected override bool FilterPage(HtmlNodeCollection pictureHtmlNode, ref int pageNum)
{
if (base.FilterPage(pictureHtmlNode, ref pageNum))
{
return true;
}
if (pictureHtmlNode.Count() <= 1)
{
var picNode = pictureHtmlNode.FirstOrDefault();
if (picNode == null)
{
pageNum = 500;
return true;
}
var picturePathName = picNode.Attributes["src"].Value;
if (picturePathName.Contains("bctp_28.gif"))
{
pageNum = 500;
return true;
}
}
return false;
}