我试图在我的 VB 代码中通过标签名称获取元素,就像我以前在 VBA 中一样,但无法弄清楚如何。我打开一个新的浏览器窗口,但从那时起代码就卡住了。
Public ie As New SHDocVw.InternetExplorer
Private Sub TEST(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Keyword As Long
ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.Navigate("http://google.com/")
Do Until ie.ReadyState = SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE
Application.DoEvents()
Loop
Dim Doc As HtmlDocument
Doc = ie.Document
Keyword = Doc.GetElementsByTagName("td")(8).InnerText
MsgBox(Keyword)
End Sub