I'm trying to access all the information on the following table:
https://www.tradingview.com/markets/stocks-usa/sectorandindustry-industry/biotechnology/
using the following VBA code:
Sub GetInfo()
Dim XMLPage As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument
Dim HTMLTable, HTMLRow, HTMLCell, button As MSHTML.IHTMLElement
XMLPage.Open "GET", "https://www.tradingview.com/markets/stocks-usa/sectorandindustry-industry/biotechnology/", False
XMLPage.send
HTMLDoc.body.innerHTML = XMLPage.responseText
Set HTMLTable = HTMLDoc.getElementsByTagName("tr")
For Each HTMLRow In HTMLTable
For Each HTMLCell In HTMLRow.Children
Debug.Print HTMLCell.innerText
Next HTMLCell
Next HTMLRow
End Sub
This works great but isn't capable of getting everything on the page. On the bottom of the page, there is a button you must click to "Load More" information. I think the button is defined below:
<div class="tv-load-more tv-load-more--screener js-screener-load-more">
<span class="tv-load-more__btn">Load More</span>
I've tried a few different methods but haven't found success yet. Is there a way to automate VBA to keep clicking that button until everything is loaded, then run the VBA code above?