我想从网页获取html表中的数据。我获得了第一个表格数据,但无法获得第二个表格数据,从第二个表格中我得到了70个权限被拒绝'。如何解决这个问题。如何获取第二个表data.first表数据对我来说没有必要。我只需要获得第二个表数据。
Sub Fetcher()
Dim IE As Object
Dim doc As Object
Dim colTR As Object
Dim colTD As Object
Dim tr As Object
Dim td As Object
Dim username As String
Dim password As String
Dim pages As Integer
Dim rows As Integer
Dim cols As Integer
Dim isbrowser As Boolean
Dim html As Object
username = "user"
password = "pswd"
' MsgBox username & "-" & password & "-" & pages & "-" & isbrowser
Const login As String = "http://crbt.zong.com.pk/colorring/serviceprovider/enter.jsp"
On Error GoTo Err_Login
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = isbrowser
With IE
.Navigate login 'address of log in page
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
'this information is specific to the web page
With .Document.forms(0)
.opername.Value = username
.password.Value = password
''MsgBox "login"
.submit
End With
' MsgBox "Fetching start..."
If pages = 0 Then
url = "http://crbt.zong.com.pk/colorring/serviceprovider/spRingList.jsp"
With IE
.Navigate url
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
With .Document.forms(0)
.Page.Value = 12
.searchmodel.Value = "buytimes"
.op.Value = "search"
' MsgBox .Page.Value
'MsgBox .searchmodel.Value
'MsgBox .op.Value
.submit
'MsgBox "Desired Page is Open"
Set doc = IE.Document
Set colTR = doc.getElementsByTagName("TR")
For Each tr In colTR
Set colTD = tr.getElementsByTagName("TD")
For Each td In colTD
MsgBox td.innerText
Next td
Next tr
End With
End With
End If
'MsgBox pages
End With
Exit_Login:
Exit Sub
Err_Login:
MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbCritical, "Error"
Resume Exit_Login
End Sub