저는 지금 당분간이 일을하는 법을 알아 내려고 노력해 왔습니다. 나는 아래의 코드로 잘 할 수있는 "live_"의 형식 classname을 찾고 싶습니다. 그러나 전체 코드를 반복하고 다른 모든 양식 텍스트를 얻지 않고 해당 양식 태그 내 에서 텍스트 값을 가져 오는 방법을 확신 할 수 없습니다. 값.
내 winform에 대한 웹 브라우저 컨트롤을 사용하고 있습니다.
양식 태그를 가져와야하는 코드는 다음과 같습니다.
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_ 라는 클래스 이름이 있는지 확인 합니다. 이 코드는 잘 작동하며 해당 클래스에 의해 모든 양식 태그를 찾습니다. 그러나 일부 양식 태그에는 해당 클래스가 있지만 해당 양식 태그 내에서만 검색하려는 텍스트 상자가 없습니다.
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>
그래서 제 질문은 : 내가 아니라 현재의 폼 태그 지역을 통해보고하고 그 텍스트 상자가 있는지 찾아 가야합니까 방법 (( "제목") .GetAttribute을 ToString.ToLower이 = "코멘트를 작성".)?
나는 다음을 시도했다.
Dim theElementCollection2 As HtmlElementCollection = Nothing
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("className").ToLower.Contains("live_") Then
Dim theID As String = curElement.GetAttribute("data-live")
theElementCollection2 = curElement.Document.GetElementsByTagName("textarea")
For Each curElement2 As HtmlElement In theElementCollection2
Debug.Print(curElement2.GetAttribute("title").ToLower.ToString)
If curElement2.GetAttribute("title").ToLower.ToString = "write a comment..." Then
Debug.Print("Found! " & curElement2.GetAttribute("name"))
End If
Next
End If
Next
하지만 그것은 여전히 전체 HTML 페이지를 통해서만 반복됩니다 ...
시간과 도움에 감사드립니다!