Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

paulosemblano

Web Scraping na página InfoMoney

Recommended Posts

paulosemblano

Tenho o código abaixo que acessa a página da InfoMoney e seleciona a opção Todos do botão para retornar todos os resultados. O problema é que só seleciona, mas não clica para retornar todas as cotações.

Sub GetHtmlDocument()
    Dim IE              As New SHDocVw.InternetExplorer
    Dim HTMLDoc         As MSHTML.HTMLDocument
    Dim HTMLOptions     As MSHTML.IHTMLElementCollection
    Dim HTMLOption      As MSHTML.IHTMLElement
    IE.Visible = True
    IE.navigate "https://www.infomoney.com.br/ibovespa"
    Do While IE.ReadyState <> READYSTATE_COMPLETE
    Loop
    Set HTMLDoc = IE.Document
    Set HTMLOptions = HTMLDoc.getElementsByTagName("option") 'É um botão
    For Each HTMLOption In HTMLOptions
        If HTMLOption.innerText = "Todos" Then
            HTMLOption.Selected = True
            Exit Sub
        End If
    Next HTMLOption
End Sub

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.