I need to scrape some info from web, using vba. This is an extract of my code. It's ok, but the site has 2 classes with the same name. So my code writes only the last value. I want that:
Sheets("01").Range("DW" & number) = source.getAttribute("data-id")
writes only the first value of class "sample" found on site.
How can I do? Thanks
With http
.Open "GET", site, False
.send
html.body.innerHTML = .responseText
End With
For Each source In html.getElementsByClassName("sample")
Sheets("01").Range("DW" & number) = source.getAttribute("data-id")
Next source
Next number
Next number-statement but no matchingFororFor Each?