I am trying to extract specific data from a website and load it into my Excel worksheet.
For example, I want to extract the Metascore from https://www.metacritic.com/game/sid-meiers-civilization-vi/. This information is located within a specific element.
Private Sub URL_Load(ByVal sURL As String)
'Variablen deklarieren
Dim appInternetExplorer As Object
Dim htmlTxt As String
Dim spanTxt2 As String
Set appInternetExplorer = CreateObject("InternetExplorer.Application")
appInternetExplorer.navigate sURL
Do: Loop Until appInternetExplorer.Busy = False
Do: Loop Until appInternetExplorer.Busy = False
spanTxt = appInternetExplorer.document.DocumentElement.all.tags("SPAN")
'objSelect = appInternetExplorer.document.DocumentElement.all.tags("SPAN")
Debug.Print htmlTxt
Set appInternetExplorer = Nothing
Close
'Mache hier irgendwas mit dem Text: Parsen, ausgeben, speichern
MsgBox "Der Text wurde ausgelesen!"
End Sub
In this code, the variable "spanTxt" is described with the following value: X. Unfortunately, this is not the element I want to extract.
How can I extract a specific element?
I tried:
htmlTxt = appInternetExplorer.document.DocumentElement.outerHTML
htmlTxt1(1) = appInternetExplorer.document.DocumentElement.innerHTML
htmlTxt2 = appInternetExplorer.document.DocumentElement.innerText

appInternetExplorer.documenis blank. You can check it in VBELocals Window.