I am trying to scrape a table from the website fltplan.com. I have been able to login utilizing VBA. I run into issues when trying to scrape the active flight plan table. The code I am utilizing to login is:
I was unable to utilize the above code in its entirety but it worked great for the login. After the login is where I ran into trouble.
I am fairly new with IE automation but I think that if I was able to navigate the web page utilizing the buttons to the place where my table is I would have better luck. I also have been unable to determine a table ID for the data that I want. but I need to successfully navigate there first. Two buttons need pressed to get to my data.
This is the code when I select inspect element for the first button:
<input class="TitleButton" value="Flight Planning" *******="CheckB1(this)" type="button">
And this is for the second button:
<input class="FPButtons" value="Flight Listing • " type="submit">
Any help would be appreciated. Thanks
Code:
Sub GetTable()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "http://www.fltplan.com/"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.UserName.Value = "myusername"
.Password.Value = "mypassword"
.submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "https://www.fltplan.com/AwRegUserCk.exe?a=1"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'get the table based on the table’s id
Set ieDoc = ieApp.Document
Set ieTable = ieDoc.all.Item("fpc2")
'copy the tables html to the clipboard and paste to the sheet
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "" & ieTable.outerHTML & ""
clip.PutInClipboard
Sheet10.Select
Sheet10.Range("C3").Select
Sheet10.PasteSpecial "Unicode Text"
End If
I was unable to utilize the above code in its entirety but it worked great for the login. After the login is where I ran into trouble.
I am fairly new with IE automation but I think that if I was able to navigate the web page utilizing the buttons to the place where my table is I would have better luck. I also have been unable to determine a table ID for the data that I want. but I need to successfully navigate there first. Two buttons need pressed to get to my data.
This is the code when I select inspect element for the first button:
<input class="TitleButton" value="Flight Planning" *******="CheckB1(this)" type="button">
And this is for the second button:
<input class="FPButtons" value="Flight Listing • " type="submit">
Any help would be appreciated. Thanks
Last edited: