WebBrowser中的InnerHtml

时间:2018-11-14 20:10:17

标签: vb.net

我需要InnerHtml方面的帮助。

enter image description here

我怎么知道其中一个将颜色更改为绿色?它需要具体。不是WebBrowser1.document.body.innertext.contains("Green")

类似这样:

If WebBrowser1.Document.GetElementById("data-search_id ="1740").InnerText.Contains("background-color: Green;") Then
    Label1.Text = ("Working")
End if

这不起作用,因为data-search_id ="1740"不是id。我认为它必须是InnerHtml data-search_id ="1740"InnerText.contains之类的东西。

(这是绿色时的外观:background-color: Green;

我尝试了几件事。示例:

Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

For Each webpageelement As HtmlElement In allelements
    If webpageelement.GetAttribute("data-search_id") = "1762".Contains("background-color: green;") Then
         Label1.Text = "Working"
    End If
Next

1 个答案:

答案 0 :(得分:0)

int chunks = 3;
int[] ix = new int[chunks];
int index = url.length();
for(int a = ix.length-1; a >= 0; a--) index = url.lastIndexOf('/', (ix[a] = index)-1);
StringBuilder sb = new StringBuilder(url.length() - index - chunks);
for(int next: ix) sb.append(url, index+1, index = next);
String result = sb.toString();