Forum Discussion

Silent_Warrior5's avatar
Silent_Warrior5
Copper Contributor
Jun 10, 2020

Excel VBA Load Data from HTML Website without CreateObject("InternetExplorer.Application")

Hi all,

 

i will load data from a html website. the problem is i can not use "CreateObject("InternetExplorer.Application")" because the site don't load in the internet explorer. In Firefox the side works.

i need all data in the blue boxes from all 4 Areas

 

i test it with getElementsByTagName and getElementById but dont work 😞

 

can someone help me?

 

 

Sub Extract_data()

    Dim url As String, links_count As Integer
    Dim i As Integer, j As Integer, row As Integer
    Dim XMLHTTP As Object, html As Object
    Dim tr_coll As Object, tr As Object
    Dim td_coll As Object, td As Object

    links_count = 1
    For i = 0 To links_count

        url = ""

        Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
        XMLHTTP.Open "GET", url, False
        XMLHTTP.send

        Set html = CreateObject("htmlfile")
        html.body.innerHTML = XMLHTTP.responseText

        Set tbl = html.getElementsByTagName("location-container")

        Set tr_coll = tbl(0).getElementsByTagName("TD") 

        For Each tr In tr_coll
            j = 1
            Set TD_col = tr.getElementsByTagName("TD")

            For Each td In TD_col
                Cells(row + 1, j).Value = td.innerText
                j = j + 1
            Next
            row = row + 1
        Next
    Next

    MsgBox "Done"
End Sub

 

 

 

 

thx and cheers

silent

 

  • Kageyaiba's avatar
    Kageyaiba
    Copper Contributor

    Silent_Warrior5I have pretty much the same problem. It's incredibly frustrating to learn some code as a non-programmer in order to get dynamic data, just to find out that Excel is only compatible with the extremely outdated Internet Explorer. Help from the community would be greatly appreciated

    • dantt_Bloggs's avatar
      dantt_Bloggs
      Copper Contributor

      You can use selenium technology for Web Capture, which supports chrome browsers and edge browsers.Kageyaiba 

Resources