У меня есть этот рабочий код, который я использую для получения данных из DIVS.
Для этого примера у меня есть фрукты в качестве категории.
Я хотел бы получить все фрукты и рядом с ними название категории.
HTML выглядит так
<DIV style="HEIGHT:100%;WIDTH:100%" ID="oReportDiv">
<DIV class="a69"> Fruits </DIV>
<DIV style="word-wrap:break-word;text-decoration:none;"
class="a92">Banana</DIV>
<DIV style="word-wrap:break-word;text-decoration:none;"
class="a92">Mango</DIV>
<DIV style="word-wrap:break-word;text-decoration:none;"
class="a92">Apple</DIV>
</DIV>
Выполнение кода выдает:
Banana Fruit
Mango
Apple
Но мне нужно:
Banana Fruit
Mango Fruit
Apple Fruit
Как мне этого добиться?
ОБНОВЛЕНИЕ: я забыл опубликовать код
t = Timer
Do
DoEvents
On Error Resume Next
Set nodeList = .document.querySelectorAll("#oReportCell .a92")
Set nodeList1 = .document.querySelectorAll("#oReportCell .a69")
On Error GoTo 0
If Timer - t > MAX_WAIT_SEC Then Exit Do
Loop While nodeList Is Nothing
If Not nodeList Is Nothing Then
With ThisWorkbook.Worksheets("Sheet1")
'This nodeList is retrieving the values inside the DIV class="a69"
'it's a list of products
For i = 0 To nodeList.Length - 1
.Cells(i + 1, 1) = nodeList.Item(i).innerText
Next
'This nodeList1 is retrieving the value inside the DIV class="a92"
'it's the name of the product (so only one value)
For i = 0 To nodeList1.Length - 1
.Cells(i + 1, 8) = nodeList1.Item(i).innerText
Next
End With
End If