visual studio - VB.NET How to get text from an HTML table? -


i'm trying access tables , values html page inside of webbrowser control. here's i'm trying access:

https://gyazo.com/c4312f860397d0f86ccce425d1fb3d48

in end, i'm trying access value="100" inside of input name="server[players]". there way this? i'm not using external addons visual studio or anything. i've gotten working:

private sub button1_click(sender object, e eventargs) handles button1.click     dim divs = webbrowser1.document.getelementsbytagname("div")     each div htmlelement in divs         if div.getattribute("id") = ("statusdetail-ajax")             dim status string = div.innertext             label1.text = status         end if     next 

which shows me online/offline status. appreciated!

you want getattribute() method, so:

private sub displaymetadescription()   if (webbrowser1.document isnot nothing)     dim elems htmlelementcollection      dim weboc webbrowser = webbrowser1      elems = weboc.document.getelementsbytagname("meta")      each elem htmlelement in elems       dim namestr string = elem.getattribute("name")        if ((namestr isnot nothing) , (namestr.length <> 0))         if namestr.tolower().equals("description")           dim contentstr string = elem.getattribute("content")           messagebox.show("document: " & weboc.url.tostring() & vbcrlf & "description: " & contentstr)         end if       end if     next   end if end sub 

taken from: https://msdn.microsoft.com/en-us/library/system.windows.forms.htmlelement.getattribute(v=vs.110).aspx

edit:

here's same concept adapted code:

private sub button1_click(sender object, e eventargs) handles button1.click   dim inputs = webbrowser1.document.getelementsbytagname("input")   each input htmlelement in inputs     if input.getattribute("id") = ("server_players")       dim status string = input.getattribute("value")       label1.text = status     end if   next end sub 

in other words, innertext returns between elements, while getattribute() returns attribute inside element.

<element attribute="value">inner text</element>


Comments