How to list download links by VBA

1

Hello

My problem is the following ... I am accessing a website, where I provide login and password and I travel through the pages to my page of interest.

I have a function that always lists all active page links in IE.

The problem is that when I get to my page of interest, which is where a link to download .rar file is, the function to list links does not show me exactly this link of interest.

I'm new to this type of programming, so what I've built so far are blocks I've researched in forums, maybe the solution is simple, but it's not going.

Below is the code ... I can not provide information on the final page because it is private, but what matters is clicking on the download.

Sub Lista_links(IE)

Set internetdata = IE.Document
Set internetlink = internetdata.getElementsByTagName("a")

I = 1

For Each internetinnerlink In internetlink

    ActiveSheet.Cells(I, 4) = internetinnerlink.href
    I = I + 1

Next internetinnerlink
End Sub

Sub FazerLoginSite()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.application")

With IE
    .Visible = True

    .Navigate ("site primario")
    While .Busy Or .ReadyState <> 4: DoEvents: Wend

    On Error GoTo Ja_logado
    .Document.getElementById("auth_logout").Click
    While .Busy Or .ReadyState <> 4: DoEvents: Wend
    .Navigate ("site que me redireciona para o site de interesse")
    While .Busy Or .ReadyState <> 4: DoEvents: Wend

Ja_logado:
    .Navigate ("site de interesse")
    .Document.getElementById("id-username").Focus
    .Document.getElementById("id-username").Value = "meu login"
    .Document.getElementById("id-password").Focus
    .Document.getElementById("id-password").Value = "minha senha"
    .Document.forms(0).submit
    While .Busy Or .ReadyState <> 4: DoEvents: Wend

    .Navigate ("acessa um link específico na página")
    While .Busy Or .ReadyState <> 4: DoEvents: Wend
    '
    'Debug.Print .LocationURL

    Sheets("Plan1").Activate
    Call Lista_links(IE)

    .Navigate2 ("NESSA PARTE, EU ACESSO A PÁGINA QUE TEM O LINK PARA   DOWNLOAD"), CLng(2048)
    While .Busy Or .ReadyState <> 4: DoEvents: Wend


'NESSA PARTE DO CÓDIGO, QUANDO EU LISTO OS LINKS NOVAMENTE, O ÚNICO LINK QUE NÃO APARECE É O DE DOWNLOAD .RAR!
    Sheets("Plan2").Activate
    Call Lista_links(IE)

End With

'IE.Quit
Set IE = Nothing

End Sub
    
asked by anonymous 26.11.2015 / 13:57

0 answers