I need to extract some values from the table in the following website: https://www.anbima.com.br/informacoes/indicadores/.
I tried to use the solutions given in Extract table from webpage using VBA but neither worked for me.
I am rather new to VBA and I’m not familiar with java. Is there a way to extract only the values 6.869,14 and 0,35. Both are in the last column.
Here is one solution that I was able to find, however it does not seem to be the most efficient or elegant. But it works.
@W_O_L_F solution seems better, but I get an error on objHTTP.send
.
Sub scrape_quotes()
Dim browser As InternetExplorer
Dim page As HTMLDocument
Set browser = New InternetExplorer
browser.Visible = False
browser.navigate ("https://www.anbima.com.br/informacoes/indicadores/")
Do While browser.Busy: Loop
Set page = browser.document
'-----
Dim spanElement As Object, buttonElement As Object
Set spanElement = page.getElementsByClassName("linhadados")
aux = spanElement.Length
For i = 0 To spanElement.Length - 1
If VBA.Left(spanElement.Item(i).innerText, 5) = "IPCA " Then aux_indice = CDbl(VBA.Right(spanElement.Item(i).innerText, 8))
If VBA.Left(spanElement.Item(i).innerText, 5) = "IPCA1" Then aux_proj = CDbl(VBA.Right(spanElement.Item(i).innerText, 4))
Next i
browser.Quit
End Sub
2
Answers
Maybe this can get you started:
This should do it: