I'm attempting to extract a table from the Drainage Services Department website. I've written the VBA code below, but it doesn't seem to be working. I suspect that the issue lies in the fact that this particular table is generated using JavaScript. Any suggestions on how to resolve this problem?
Sub DSD()
Dim ie As New InternetExplorer
Dim html As New HTMLDocument
Dim url As String
url = "https://www.dsd.gov.hk/EN/Tender_Notices/Current_Tenders/index.html"
ie.Visible = False
ie.navigate url
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set html = ie.document
Dim lists As IHTMLElementCollection
Dim anchorElements As IHTMLElementCollection
Dim ulElement As HTMLUListElement
Dim liElement As HTMLLIElement
Dim row As Long
Set lists = html.getElementsByClassName("ncol-md-12 result")
row = 1
For Each ulElement In lists
For Each liElement In ulElement.getElementsByTagName("tbody")
Set anchorElements = liElement.getElementsByTagName("td")
If anchorElements.Length > 0 Then
Cells(row, 1) = anchorElements.Item(0).innerText
row = row + 1
End If
Next liElement
Next ulElement
ie.Quit
End Sub
I'm aiming to scrape data from the above-mentioned website.