Vb.net Webbrowser GetElementsByTagName在该标记区域内循环
一段时间以来,我一直在想如何着手做这件事。我想找到“live_uuu”的表单类名,我可以用下面的代码来做,但是我不确定如何在表单标签中获取文本值,而不必循环整个代码并获取页面上的其他表单文本值 我正在winform上使用webbrowser控件 我必须获取表单标签的代码如下:Vb.net Webbrowser GetElementsByTagName在该标记区域内循环,vb.net,dom,webbrowser-control,html-agility-pack,getelementsbytagname,Vb.net,Dom,Webbrowser Control,Html Agility Pack,Getelementsbytagname,一段时间以来,我一直在想如何着手做这件事。我想找到“live_uuu”的表单类名,我可以用下面的代码来做,但是我不确定如何在表单标签中获取文本值,而不必循环整个代码并获取页面上的其他表单文本值 我正在winform上使用webbrowser控件 我必须获取表单标签的代码如下: Dim theElementCollection As HtmlElementCollection = Nothing theElementCollection = wbNewsFeed.Document.GetElem
Dim theElementCollection As HtmlElementCollection = Nothing
theElementCollection = wbNewsFeed.Document.GetElementsByTagName("form")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("className").ToLower.Contains("live_") Then
Dim theID As String = curElement.GetAttribute("data-live")
End If
Next
上面的代码当前循环,直到在该页面中找不到更多的表单标记。如果它找到一个表单标记,那么它会查看该表单标记的名称的任何部分是否包含一个类名live\uu。这段代码工作得很好,并且确实找到了该类的所有表单标记。但是,有些表单标记仍然有该类,但没有文本框,我只想在该表单标记中搜索
html与此类似:
<form class="live_574bf67566_58vvifkfkyu5237 commentable expand_mode" id="0_f"
onsubmit="return window.Event &&" action="change.php" method="post"
data-ft='{"ge":"]"}' rel="async" data-live='{"seq":"574bf67566_1857067654230"}'>
<input name="charset_test" type="hidden" value="6,52g,6b88">
<input name="fb_dtsg" type="hidden" value="AQB4SLmU" autocomplete="off">
[LOT of code here....]
<input class="hiddenInput" type="hidden" autocomplete="off" data-id="785fgj67-774">
<div class="innerWrap" data-reactid=".1l.1:4.0.$right.0.0.0.0.1.0.1">
<textarea name="add_comment_text" title="Write a comment..." class="textInput mentions" placeholder="Write a comment..." value="Write a comment..." data-id="57-986-gn-52">Write a comment...</textarea>
</div>
[some more code here]
</form>
但这似乎只在整个html页面中循环
谢谢你的时间和帮助 似乎您需要:
curElement.Children.GetElementsByName("add_comment_text")(0)
curElement.Children.GetElementsByName("add_comment_text")(0)