我正在尝试解析 HTMLNode 的所有子项,其中子项不是使用 HtmlAgility vb.net 中的隐藏输入。
使用以下代码:
If node.InnerHtml.Length > 10000 Then
'Parse the current node's child nodes
For Each child As HtmlNode In node.ChildNodes _
.Where(Function(c) c.NodeType <> HtmlNodeType.Text _
AndAlso c.NodeType <> HtmlNodeType.Comment _
AndAlso c.Name <> "script" _
AndAlso c.GetAttributeValue("type", "no").ToString() IsNot "hidden")
RecursiveHtmlParse(child)
Next
End If
不幸的是,隐藏的输入子节点仍在解析中。我已经尝试了几个小时,只是无法让foreach跳过它们。
任何帮助将不胜感激。
提前感谢!!
VB.NET 中的Is
和IsNot
运算符检查引用相等性。包含相同值的两个字符串实际上可能引用内存中的不同对象。
试试这个:
AndAlso c.GetAttributeValue("type", "no") <> "hidden"
或者这个
AndAlso Not c.GetAttributeValue("type", "no").Equals("hidden")