jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
URL in E1 is: https://www.tesco.com/groceries/en-GB/shop/fresh-food/all?include-children=true&page=1&count=48
I am trying to get the outertext, which should for example return:
Tesco British Salted Block Butter 250G↵Write a review↵↵Sorry, this product is currently unavailable↵↵Rest of ↵Block Butter↵shelf
Any ideas please?
I am trying to get the outertext, which should for example return:
Tesco British Salted Block Butter 250G↵Write a review↵↵Sorry, this product is currently unavailable↵↵Rest of ↵Block Butter↵shelf
Any ideas please?
Code:
Public Sub Data_Pull_Products_and_Prices_2()
Dim http As Object, html As New HTMLDocument, topics As Object, topics2 As Object, titleElem As Object, topic As HTMLHtmlElement
Dim i As Integer
Dim j As Integer
Dim rngURL As Range
Dim LastRow As Long
Dim LastRow2 As Long
Application.ScreenUpdating = False
Set http = CreateObject("MSXML2.XMLHTTP")
For Each rngURL In Worksheets("Sheet1").Range("E1", Worksheets("Sheet1").Range("E" & Rows.Count).End(xlUp))
http.Open "GET", rngURL, False
http.send
html.body.innerHTML = http.responseText
'Do While http.readyState <> 4
DoEvents
'Loop
Set topics = html.getElementsByClassName("product-details--wrapper")
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
i = LastRow + 1
For Each topic In topics
Set titleElem = topic.getElementsByTagName("div")(0)
Sheets(1).Cells(i, 1).Value = titleElem.getElementsByTagName("a")(0).outerText
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
i = 1 + LastRow
Next
Next
End Sub