When using the 'HTML_XMLHTT' sub I only get(replaced '<'/'>' with '#'):
And with the 'HTML_IE' sub, I get the document. So how do I prevent the error using 'XMLHTTP'?#HEAD##/HEAD#
#BODY#
#CENTER#
#H1#404 Not Found#/H1##/CENTER#
#HR#
#CENTER#nginx/1.14.0#/CENTER#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#!-- a padding to disable MSIE and Chrome friendly error page --#
#/BODY#
Code:
Option Explicit
Private Const URL As String = "https://www.oslobors.no/ob_eng/" _
& "markedsaktivitet/#/details/EQNR.OSE/overview"
Private Sub HTML_XMLHTTP()
Dim oXMLHTTP As Object
Dim htmlObj As Object
Sheet1.Cells.Clear
Set htmlObj = CreateObject("htmlfile")
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
With oXMLHTTP
.Open "GET", URL, False
.send
htmlObj.body.innerHTML = .responseText
End With
Call Get_DOM(htmlObj)
End Sub
Private Sub HTML_IE()
Dim IE As Object
Sheet1.Cells.Clear
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate URL
Do Until .readyState = 4
DoEvents
Loop
Call Get_DOM(IE.Document)
.Quit
End With
End Sub
Private Sub Get_DOM(HTMLDoc As Object)
Dim arr() As String
Dim vItem As Variant
Dim i As Integer
Dim objHtml As Object
Set objHtml = HTMLDoc.getElementsByTagName("html")
arr = Split(objHtml(0).innerHTML, vbLf)
For Each vItem In arr
i = i + 1
Cells(i, 1).Value = vItem
Next vItem
End Sub
Last edited: