本文整理汇总了C#中HtmlAgilityPack.HtmlNodeCollection.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNodeCollection.FirstOrDefault方法的具体用法?C# HtmlNodeCollection.FirstOrDefault怎么用?C# HtmlNodeCollection.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNodeCollection
的用法示例。
在下文中一共展示了HtmlNodeCollection.FirstOrDefault方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetConvertedManaCost
private static void SetConvertedManaCost(ScrappedCardModel scrappedCard, HtmlNodeCollection table)
{
var row = table.FirstOrDefault(x => x.ChildNodes[1].InnerText.Contains("Converted Mana Cost"));
if (row != null) scrappedCard.ConvertedManaCost = int.Parse(row.ChildNodes[2].InnerText.Trim());
}
示例2: SetExpansion
private static void SetExpansion(ScrappedCardModel scrappedCard, HtmlNodeCollection table)
{
var row = table.FirstOrDefault(x => x.ChildNodes[1].InnerText.Contains("Expansion"));
if (row != null) scrappedCard.Expansion = row.ChildNodes[2].InnerText.Trim();
}
示例3: SetPowerAndThoughness
private static void SetPowerAndThoughness(ScrappedCardModel scrappedCard, HtmlNodeCollection table)
{
var row = table.FirstOrDefault(x => x.ChildNodes[1].InnerText.Contains("P/T"));
if (row != null)
{
var pt = row.ChildNodes[2].InnerText.Trim().Trim('(', ')').Split('/');
scrappedCard.Power = pt[0];
scrappedCard.Thoughness = pt[1];
}
}
示例4: SetTypes
private static void SetTypes(ScrappedCardModel scrappedCard, HtmlNodeCollection table)
{
var row = table.FirstOrDefault(x => x.ChildNodes[1].InnerText.Contains("Types"));
if (row != null) scrappedCard.Types = row.ChildNodes[2].InnerText.Trim().Replace(" —", "").Split(' ').ToList();
}
示例5: SetManaCost
private static void SetManaCost(ScrappedCardModel scrappedCard, HtmlNodeCollection table)
{
var row = table.FirstOrDefault(x => x.ChildNodes[1].InnerText.Contains("Mana Cost"));
if (row != null)
{
foreach (var childNode in row.ChildNodes[2].ChildNodes)
{
if (childNode.Name == "#text")
continue;
var alt = childNode.GetAttributeValue("alt", "");
if (alt.Contains("CMC"))
{
if (alt.Length > 4)
{
scrappedCard.ColorlessMana = alt[3].ToString() + alt[4];
}
else
{
scrappedCard.ColorlessMana = alt[3].ToString();
}
}
else if (alt.Contains("Color R"))
{
scrappedCard.RedMana++;
}
else if (alt.Contains("Color U"))
{
scrappedCard.BlueMana++;
}
else if (alt.Contains("Color G"))
{
scrappedCard.GreenMana++;
}
else if (alt.Contains("Color W"))
{
scrappedCard.WhiteMana++;
}
else if (alt.Contains("Color B"))
{
scrappedCard.BlackMana++;
}
}
}
}
示例6: 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;
}
示例7: GetNodeForUrl
internal static HtmlNode GetNodeForUrl(HtmlNodeCollection nodes, string url) {
var hrefNode = nodes.FirstOrDefault(n => n.GetAttributeValue("href", "").Contains(url));
return hrefNode;
}
示例8: GetMetaProperty
private static string GetMetaProperty(HtmlNodeCollection nodes, string prop)
=> nodes.FirstOrDefault(x => x.Attributes["property"]?.Value == prop)?.Attributes["content"]?.Value;
示例9: GetInfoElem
private HtmlNode GetInfoElem(HtmlNodeCollection nodes, string title) {
return nodes.FirstOrDefault(n => n.SelectNodes("span[text() = '" + title + " :']") != null);
}