我想获取WebBrowser中所有的Input标签,现在用的是比较笨的方法:
Dim webDoc As Object
Dim webTag As Object
Dim lengthTag As Integer
Dim countTag As Integer
Set webDoc = IE.Document.All
lengthTag = webDoc.Length - 1
For countTag = 0 To lengthTag
Set webTag = webDoc.Item(countTag)
Select Case Strings.LCase(webDoc.Item(countTag).tagName)
Case "input"
......
End Select
Next这样虽然可以达到目的,但是当网页内容很多时速度很慢,记得有可以不必全部枚举而直接获取某一类标签的方法,哪位朋友知道的写一下代码吧,提示一下也好,谢谢了!
Dim webDoc As Object
Dim webTag As Object
Dim lengthTag As Integer
Dim countTag As Integer
Set webDoc = IE.Document.All
lengthTag = webDoc.Length - 1
For countTag = 0 To lengthTag
Set webTag = webDoc.Item(countTag)
Select Case Strings.LCase(webDoc.Item(countTag).tagName)
Case "input"
......
End Select
Next这样虽然可以达到目的,但是当网页内容很多时速度很慢,记得有可以不必全部枚举而直接获取某一类标签的方法,哪位朋友知道的写一下代码吧,提示一下也好,谢谢了!
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim oDoc As HTMLDocument
Dim oElement As IHTMLElement
Dim oElements As IHTMLElementCollection
Set oDoc = pDisp.Document
Set oElements = oDoc.getElementsByTagName("input")
If Not oElements Is Nothing Then
For Each oElement In oElements
Debug.Print oElement.outerHTML
Next
End IfEnd Sub