shahin
Active Member
Hi there! Hope you all are doing well. So far when I worked with vba to fetch web data I used either "class" or "tag" name to parse that. But, in case of applying "ID" I got stuck. Using class name I can get the data from this site but when I trend to apply "ID" to get the same it throws error. Perhaps I'm doing something wrong which I can't identify. Hope somebody out there will help me to accomplish this. Thanks in advance.
Code:
Sub FashionStuff()
Dim http As New MSXML2.XMLHTTP60, html As New HTMLDocument
Dim elements As Object, element As Object, post As Object
With http
.Open "GET", "https://www.sephora.ae/en/stores/", False
.send
html.body.innerHTML = .responseText
End With
Set elements = html.getElementById("mm-makeup-nav-item")
Set element = elements.getElementsByTagName("a")
For Each post In element
x = x + 1
Cells(x, 1) = post.href
Next post
Set http = Nothing: Set elements = Nothing: Set element = Nothing
End Sub