Web scrapping - how to fetch data from website using vba

Web scrapping - how to fetch data from website using vba


Sub getdata()
    Dim ie As New InternetExplorer
    Dim htm As HTMLDocument
    
    ie.Visible = True
    ie.Navigate "https://quotes.toscrape.com/"
    
    Do While ie.ReadyState <> READYSTATE_COMPLETE Or ie.Busy = True: Loop
    Application.Wait Now() + TimeValue("00:00:03")
    
    Set htm = ie.Document
    
    For i = 0 To htm.getElementsByClassName("quote").Length - 1
        Sheet2.Range("A1").Offset(i, 0).Value = htm.getElementsByClassName("quote")(i).innerText
    Next i
    
    ie.Quit
End Sub

Subscribe my Channel

Akash Vishwakarma

Hi This is Akash Vishwakarma. I am working as software developer. I have knowledge in VBA, SQL Server, Python. I have developed this website from Django Framework for given traning.