无法通过VB中的TagName获取HTML元素
问题描述:
我想通过VB代码中的标签名称获取元素,就像我曾经在VBA中那样,但无法弄清楚如何。我打开了一个新的浏览器窗口,然后代码就卡住了。无法通过VB中的TagName获取HTML元素
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
答
的问题,通过加入
Imports mshtml
在代码的顶部解决。