mardi 31 août 2021

How can I pull data from website table using vba

I have a problem writing code that will pull data from a web page. The first part of the code works well, but the second part I can't write correctly to pulls the data from the table from the site. The problem is the "td" tags, I need the data contained in the "td" tags, all of them or some of them. I have tried in many ways but I have not succeeded. Can anyone help me with the code that will pull this data from the table?

This is the code I have:

Sub provera_TR_klijenta()

    'check in References: _
    Microsoft Internet Controls _
    Microsoft HTML Object Library
    
    Dim objIE As InternetExplorer 'special object variable representing the IE browser
    Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
    
    Dim ieDoc As MSHTML.HTMLDocument
    Dim iframeDoc As MSHTML.HTMLDocument
    
    'initiating a new instance of Internet Explorer and asigning it to objIE
    Set objIE = New InternetExplorer
    
    'make IE browser visible (False would allow IE to run in the background)
    objIE.Visible = True
    objIE.Width = 1000
    objIE.Height = 800
    
    'navigate IE to this web page (a pretty neat search engine really)
    objIE.navigate "https://nbs.rs/en/drugi-nivo-navigacije/servisi/jedinstveni-registar-racuna/index.html"
    'wait here a few seconds while the browser is busy
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
    
    Set ieDoc = objIE.document
    Set iframeDoc = ieDoc.frames(0).document
    
    iframeDoc.getElementsByName("matbr")(1).Value = "21122017"
    iframeDoc.getElementsByName("Submit")(0).Click
    
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
    
    '*** I don't know what to do from here ***

End Sub

The html code is on this link: https://codebeautify.org/alleditor/cbf73981




Aucun commentaire:

Enregistrer un commentaire