I have this example code where a method is used to extract text from a web page. In the complete code, these pages are then used to extract a whole series of data very quickly. The complete code has stopped working because this part used to extract only the text from the web page has stopped working correctly, or rather it still works if I use Excel 2010 while it has stopped working correctly for a couple of years on Excel 365, probably after some update. Instead of returning only the text, it returns a mixture of JavaScript, CSS, and text. Another strange thing is that it works regularly for an acquaintance of mine who works with Office 365 Enterprise. Do you see any possibility of making it work on Excel 365 as well, or is it an Excel bug? The example code to show only the non-functioning part is as follows:
Sub EstraiTestoDaPaginaWeb()
Dim xmlHttp As Object
Dim html As Object
Dim testoEstratto As String
Dim elem As Object
' Creazione dell'oggetto XMLHTTP
Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
' URL della pagina web
Dim url As String
url = "https://www.borsaitaliana.it/borsa/obbligazioni/mot/btp/scheda/IT0001086567.html?lang=it"
' Invio della richiesta
xmlHttp.Open "GET", url, False
xmlHttp.send
' Creazione dell'oggetto HTMLDocument
Set html = CreateObject("HTMLFILE")
html.body.innerHTML = xmlHttp.responseText
' Estrazione del testo
testoEstratto = html.body.innerText
' Visualizzare il testo estratto
MsgBox testoEstratto
End Sub
Excel 365 Results:
Excel 2010 Results:
I don't know English and I use translators to communicate, so I'm afraid I might not have been clear. I'd like to try to simplify my question: is there a way to achieve the result shown in the attached images using Excel 365? And why do you think the sample code posted above continues to work with Excel 2010 but is no longer valid for today's Excel 365? It's the code that I don't understand and why it doesn't work anymore. You can also replace the borsaitaliana URL with any website you want.


Excelrather some other API's. Please adjust tags according to it.