How can I use a selector to check if the content of "alt" is "Meeting" or "Canceled"?
<body>
<div class="mainBox">
<li class="content">
<img class="title" src="https://url_01/images/img01.gif" alt="Meeting">
</li>
<li class="content">
<img class="title" src="https://url_02/images/img02.gif" alt="Meeting">
</li>
<li class="content">
<img class="title" src="https://url_03/images/img03.gif" alt="Canceled">
</li>
<li class="content">
<img class="title" src="https://url_04/images/img04.gif" alt="Canceled">
</li>
</div>
</body>
Important: the selector MUST refer to class="title" because all other tags in these 4 strings occur differently often in the entire html code. Thanks
My Code:
Public Sub GetData()
Dim ohtml As New HTMLDocument
Dim elmt As Object
Dim x As Long
Set ohtml = New MSHTML.HTMLDocument
With CreateObject("MSXML2.XMLHTTP.6.0")
.Open "GET", "https:...", False
.send
ohtml.body.innerHTML = .responseText
End With
For x = 0 To elmt.Length - 1
Set elmt = ohtml.querySelectorAll("img[class='title']").Item(x) '<<== ??????
If instr(????????, "Meeting") then '<<===== ???????
ActiveSheet.Cells(x + 2, 2) = "Meeting"
Else
ActiveSheet.Cells(x + 2, 2) = "Canceled"
End If
Next
End Sub