Добрый день, не могу понять в чем проблема - переменные объявлены верно, set установлен, поиск по форумам и интернету не дает результата:
Код |
---|
Option Explicit
Public Sub Get_info()
Dim sResponse As String, i As Long, html As New HTMLDocument
Application.ScreenUpdating = False
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "[URL=https://shopping.google.es/search?q=3145891125306]https://shopping.google.es/search?q=3145891125306"[/URL];, False
.send
sResponse = StrConv(.responseBody, vbUnicode)
End With
sResponse = Mid(sResponse, InStr(1, sResponse, "<!doctype "))
Dim titles As Object, targetedInfo As Object, rowCounter As Long
With html
.body.innerHTML = sResponse
Set titles = .querySelectorAll(".SpKMTe")
Set targetedInfo = .querySelectorAll(".DX0ugf ApBhXe")
End With
With Worksheets("Sheet1")
For i = 0 To Len(targetedInfo) - 1 ' здесь ОШИБКА
If i Mod 14 = 0 Then
rowCounter = rowCounter + 1
.Cells(rowCounter, 1) = titles(rowCounter - 1).innerText
.Cells(rowCounter, 2) = targetedInfo(i).innerText
.Cells(rowCounter, 3) = targetedInfo(i + 7).innerText
End If
Next i
End With
Application.ScreenUpdating = True
End Sub |