|
VBA万岁 发表于 2014-8-19 20:19
我没有安装“按键精灵”,无法精确获知table,input标签的“索引”值(分别为7、6),故只能用以下笨办法 ...
完整代码如下:
Sub 多网页数据批量提取()
Dim ti, r As Object
Dim mM%, t%, a%, i%, j%
On Error Resume Next
mM = 0
ti = Timer
With CreateObject("internetexplorer.application")
.navigate "http://eipo.szse.cn/main/eipo/xjxx/fxrxjxx/"
Do While .Busy Or ti + 2 > Timer
DoEvents
Loop
For i = 0 To .Document.all.Length - 1
If UCase(.Document.all(i).tagname) = "TABLE" Then
t = t + 1
If .Document.all(i).Rows(0).Cells(0).innertext = "发行日" Then Exit For
End If
Next
For i = 0 To .Document.all.Length - 1
If UCase(.Document.all(i).tagname) = "INPUT" Then
a = a + 1
If .Document.all(i).innertext = "下一页" Then Exit For
End If
Next
For mM = 1 To 3
Set r = .Document.all.tags("table")(t - 1).Rows
For i = 0 To r.Length - 1
n = n + 1
For j = 0 To r(i).Cells.Length - 1
Cells(n, j + 1) = r(i).Cells(j).innertext
Cells(n, 15) = mM
Next j
Next i
Set r = Nothing
.Document.all.tags("input")(a - 1).Click
Cells(n + 1, 1).Font.Color = vbRed
ti = Timer
Do While .Busy Or ti + 2 > Timer
DoEvents
Loop
Next mM
.Quit
End With
Cells.Font.Size = 9
Cells.Columns.AutoFit
End Sub
|
|