1
Good afternoon!
I have a macro to bring information from google shopping, but I can only bring the first value you find and I would like you to bring the 3 first ones you find.
Below is the test I was doing, however I say that I am layman and I am learning, who can help me I thank.
[![Google][1]][1]
Sub TesteBusca()
Dim IE, objElementCol, objElement, ClasseValores, ItemValores As Object
Dim i As Long
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate "https://www.google.com/shopping"
.Visible = True
End With
Do Until (IE.readyState = 4 And Not IE.Busy)
DoEvents
Loop
IE.document.all("q").Value = Range("A1").Text
Set objElementCol = IE.document.getElementsByTagName("input")
For Each objElement In objElementCol
If objElement.Value = "Pesquisa Google" Then
objElement.Click
Exit For
End If
Next objElement
Do Until (IE.readyState = 4 And Not IE.Busy)
DoEvents
Loop
' tentando fazer ele passar por cada classe de "Nr22bf", onde está os valores dos itens e adicionar os 3 primeiros em cada coluna
Set ClasseValores = IE.document.getElementsByClassName("Nr22bf")
i = 1
For Each ItemValores In ClasseValores
i = i + 1
Cells(1, i) = ItemValores.innerText
Next ItemValores
' esse consigo fazer pegar apenas o primeiro resultado
'Set valor = IE.document.getElementsByClassName("Nr22bf").Item(0)
'Cells(1, 2) = valor.innerText
End Sub
[1]: https://i.stack.imgur.com/8EQ0b.jpg