Web scrapping - click on link in web browser using vba

Web scrapping - click on link in web browser using vba

Sub ClickOnWeb()

    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
    
    htm.getElementsByClassName("tag-item")(0).getElementsByTagName("a")(0).Click
    Do While ie.ReadyState <> READYSTATE_COMPLETE Or ie.Busy = True: Loop
    Application.Wait Now() + TimeValue("00:00:03")
    
    Range("A1").Value = htm.getElementsByClassName("quote")(1).innerText
    
    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.