Hi all again after a week of trying to figure out how to parse a HTML table I have yet to figure it out.
Below is the Table I am trying to get the information out of.
Below is the code I am using to Pull that information out.Code:<table class="resourceInfoTable"> <tbody> <tr> <th>Production</th> </tr> <tr> <td class="fontSize11 fontBold colorWhite">28,900</td> </tr> <tr> <th>Consumption</th> </tr> <tr> <td class="fontSize11 fontBold colorWhite">23,132</td> </tr> <tr> <td class="borderBottom"> </td> </tr> <tr> <th>Yield</th> </tr> <tr> <td class="fontSize16 fontBold fontColorRace">5,768</td> </tr> <tr> <th>Stored</th> </tr> <tr> <td class="fontSize11 fontBold colorWhite">170,000</td> </tr> </tbody> </table>
VB Code:
Public Sub Energy() Dim doc As HtmlDocument = frmWebBrowser.WebBrowser1.Document Dim tds As HtmlElementCollection = doc.GetElementsByTagName("div") For Each td As HtmlElement In tds If td.GetAttribute("id") = "planetEnergyOverview" Then Dim linkText As String = String.Empty Dim PlanetClassName As String = String.Empty For Each div As HtmlElement In td.GetElementsByTagName("table") If div.GetAttribute("className") = "resourceInfoTable" Then For Each div2 As HtmlElement In div.GetElementsByTagName("td") If div2.GetAttribute("className") = "fontSize11 fontBold colorWhite" Then linkText = div2.InnerText.Trim() If Not String.IsNullOrEmpty(linkText) Then Exit For End If End If Next End If Next frmMain.lblEnergyPro.Text = "Production: " & String.Format("{0}", linkText) End If Next End Sub
The problem I am having is that It pulls out the 28,900 fine but I need to pull the rest of the information IE the 23,132 and the 170,000 and they will get placed into other Labels. Now they are not Static numbers they change all the time to higher or lower lumbers.
Thank you for the help in advance this site is helped me get from VB6 to VB.net and learn new things I didn't know I was able to do in VB.




Reply With Quote