jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
Hello,
Trying to pull all the names of the items and then the price on this page,
https://www.tesco.com/groceries/en-GB/shop/fresh-food/all?include-children=true&page=1
e.g.
[h=3]Tesco British Salted Block Butter 250G £1.50
Tesco Gala Apple Minimum 5 Pack £1.60
But the code fails on this line:
Any ideas,
Thanks.
Trying to pull all the names of the items and then the price on this page,
https://www.tesco.com/groceries/en-GB/shop/fresh-food/all?include-children=true&page=1
e.g.
[h=3]Tesco British Salted Block Butter 250G £1.50
Tesco Gala Apple Minimum 5 Pack £1.60
But the code fails on this line:
Code:
[FONT=Verdana]Sheets(1).Cells(i, 1).Value = titleElem.getElementsByTagName("a")(0).innerText[/FONT]
[/h]
Code:
Public Sub Data_Pull()
Dim http As Object, html As New HTMLDocument, topics As Object, titleElem As Object, detailsElem As Object, topic As HTMLHtmlElement
Dim i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "https://www.tesco.com/groceries/en-GB/shop/fresh-food/all?include-children=true&page=1", False
http.send
html.body.innerHTML = http.responseText
Set topics = html.getElementsByClassName("content-wrapper")
i = 2
For Each topic In topics
Set titleElem = topic.getElementsByTagName("td")(2)
Sheets(1).Cells(i, 1).Value = titleElem.getElementsByTagName("a")(0).innerText
i = i + 1
Next
End Sub
Any ideas,
Thanks.