VBA IE Automation Logon, Navigate multiple buttons and then scrape data back into excel

wid2001

New Member
Joined
Jan 30, 2014
Messages
28
Hello All,

I am having trouble with some VBA to scrape data. I have a website (FltPlan.com) that I need to login to (I have managed to find multiple sources of code to do this and it seems pretty straight forward. Once logged in I need to navigate to a specific page on the site to scrape some data. I think the problem lies in that the links to navigate are not links but instead are buttons. It will become readily apparent by my example code that I am a novice with VBA. Here is the code I started with:

VBA Code:
Sub followWebsiteLink()

Dim IE As InternetExplorer
Dim html As HTMLDocument
Dim link As Object
Dim ElementCol As Object
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject

    Application.ScreenUpdating = False

    Set IE = New InternetExplorer
    IE.Visible = True

        IE.Navigate "https://fltplan.com"

        Do While IE.ReadyState <> READYSTATE_COMPLETE
           Application.StatusBar = "Loading website…"
        DoEvents
        Loop
        
                Set html = IE.Document
        Set ElementCol = html.getElementsByTagName("a")
        
            'fill in the login form – View Source from your browser to get the control names
    With IE.Document.forms(0)
        .UserName.Value = "IDFLT"
        .Password.Value = "12345678"
        .submit
          Do While IE.Busy: DoEvents: Loop
    Do Until IE.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    End With
 

        

        
        For Each link In ElementCol
        If link.innerHTML = "Flight Planning" Then
        link.Click
        End If
        Next link
        
        Set IE = Nothing
        Application.StatusBar = ""
        Application.ScreenUpdating = True


        
End Sub

Once logged into the site I want to click the bototn labeled. "Flight Planning" when clicked that expands a list of links/buttons. Once expanded I need to click "Flight Listing". That opens the page I need to scrape data from and paste into excel.

I know that this is setup incorrectly after the initial logging in but I am having trouble searching and finding a solution to navigate and then scrape the data. If anyone knows of an example they could point me to or has some expertise they might lend I would appreciate it.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top