VBA code to get values inside HTML

Asked

Viewed 1,518 times

1

I want to collect two values of an HTML through VBA. The information '40 New' and '$19.95'. My code can get '$19.95', but in the next iteration it overwrites and gets '$17.38'.

HTML to parse

`Set QuestionList = html.getElementById("olp_feature_div")
Set Questions = QuestionList.Children

For Each Question In Questions

If Question.className = "a-section a-spacing-small a-spacing-top-small" Then

Set QuestionFields = Question.all
For Each QuestionField In QuestionFields

If QuestionField.className = "a-color-price" Then

votes = Replace(QuestionField.innerText, "votes", "")
votes = Replace(votes, "vote", "")
Cells(RowNumber, 2).Value = Trim(votes)
End If
  • Do not understand, you want to stop the repetition in the first element found?

  • Yes, in this case, but the criterion cannot be the position, because sometimes '40 New' is the second element. If there is a way to get the element inside the class that contains the string 'new', the problem is solved. I don’t know how to do it.

  • Could you put in the full code you have? And also what website you’re using, because from what I could find, it’s an Amazon page, I even managed to get the 40 new, but I did not find the class a-color-price within the div olp_feature_div

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.