本文整理汇总了C#中HtmlAgilityPack.HtmlNode.FindHiddenField方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.FindHiddenField方法的具体用法?C# HtmlNode.FindHiddenField怎么用?C# HtmlNode.FindHiddenField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlAgilityPack.HtmlNode
的用法示例。
在下文中一共展示了HtmlNode.FindHiddenField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsePage
protected override ProductPageInfo ParsePage(HtmlNode document)
{
IEnumerable<HtmlNode> metaTags = document.QuerySelectorAll("meta");
//let if fire a NRE if some element is not found
string name = document.FindHiddenField("name").GetAttributeValue("value");
string description = metaTags.First(m => m.GetAttributeValue("property") == "og:description").GetAttributeValue("content");
string imageUrl = metaTags.First(m => m.GetAttributeValue("property") == "og:image").GetAttributeValue("content");
string priceText = document.FindHiddenField("price").GetAttributeValue("value");
return new ProductPageInfo(name, description, Decimal.Parse(priceText, NumberStyles.Currency), imageUrl);
}
示例2: GetValueSomewhereInThePage
private string GetValueSomewhereInThePage(HtmlNode document, string[] names, IEnumerable<HtmlNode> metaTags)
{
string result = null;
var possibleNames = names.SelectMany(n => new[] { n, "og:" + n });
var metaField = metaTags.FirstOrDefault(m => m.HasAttribute("property") && possibleNames.Contains(m.GetAttributeValue("property")));
if (metaField == null)
{
metaField = metaTags.FirstOrDefault(m => m.HasAttribute("name") && possibleNames.Contains(m.GetAttributeValue("name")));
}
if (metaField != null)
{
result = metaField.GetAttributeValue("content");
}
if (String.IsNullOrWhiteSpace(result))
{
foreach (var name in possibleNames)
{
var hiddenField = document.FindHiddenField(name);
if (hiddenField != null)
{
result = hiddenField.GetAttributeValue("value");
break;
}
}
}
return result;
}
示例3: ParsePage
protected override ProductPageInfo ParsePage(HtmlNode document)
{
var metaTags = document.QuerySelectorAll("meta");
//let if fire NRE if some element is not found
string name = metaTags.First(m => m.GetAttributeValue("name") == "title").GetAttributeValue("content");
string description = metaTags.First(m => m.GetAttributeValue("name") == "description").GetAttributeValue("content");
string imageUrl = metaTags.First(m => m.GetAttributeValue("property") == "og:image").GetAttributeValue("content");
var priceHidden = document.FindHiddenField("ADD_CART_ITEM<>salePriceAmt");
if (priceHidden == null)
{
priceHidden = document.FindHiddenField("ADD_CART_ITEM_ARRAY<>salePriceAmt");
}
string priceText = priceHidden.GetAttributeValue("value");
return new ProductPageInfo(name, description, Decimal.Parse(priceText, NumberStyles.Currency), imageUrl);
}