我正在使用excel vba尝试以下内容。
以下代码抛出“运行时错误70:权限被拒绝”错误。我也试过了另一种方式 - 导航到第一页,然后从第一页获取数据 - 导航到第二页并从第二页获取数据
但那也没有用。
Sub ImportAssortments()
Dim ie As InternetExplorer
Dim html As HTMLDocument
Dim i As Integer
Dim Text As HTMLDocument
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim uDD(1 To 2) As IHTMLElementCollection
Dim el As Object
b = 0
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://www.example.com"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to get Snapdeal Data... Please wait"
DoEvents
Loop
Set html = ie.document
Set uDD(1) = html.getElementsByTagName("li")
ie.navigate html.getElementById("pagnNextLink")
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to get the Data... Please wait"
DoEvents
Loop
Set html = ie.document
Set uDD(2) = html.getElementsByTagName("li")
For i = 1 To 2
For Each el In uDD(i)
If InStr(el.innerText, "stars") <> 0 Then
y = y + 1
Cells(y, 1) = el.innerText
End If
If y = 24 Then Exit For
Next el
Next i
Set ie = Nothing
Application.StatusBar = ""
End Sub