Scrape from Website with password help to download into Excel

DeeEmmEss

New Member
Joined
Nov 25, 2015
Messages
43
I am trying to scrape data from a password protected site to which I have access. My VBA currently gets me into the main page, navigates to a page I wish to download, loads the table, and then I'm stuck.
I need to direct the code to submit/hit download to excel/enter the form etc. I have tried numerous combinations without success. The code I am using is:



Dim a As String, URL As String
Set ie = CreateObject("InternetExplorer.Application")
URL = "Horse Racing Database Solutions"
With ie
.Visible = True
.Navigate URL
Do Until .ReadyState = 4
DoEvents
Loop
.Document.all.Item("Login").Value = "************"
.Document.all.Item("Password").Value = "******************"

.Document.forms(4).submit


End With
URL = "Daily Jockeys Report"


ie.Navigate URL
'Stuck with next line
Set HTMLButton = ie.Document.getElementsByTagName("Download to Excel")
' ie.Document.Item("downloadbutton") = Click
HTMLButton.Click

Which gets me to where I need to download the table. Below is extracted from the page concerned.

<td title="Download the Jockey report">
<form action="dailyjockeysexcel.php" method="post"><input name="user" type="hiddenvalue="28321">
<input name="totem" type="hidden" value="8bb3fe04b9ce63f2c86bf2ee7c30a3313c66dca2">
**<input title="Download to Excel" class="downloadbutton" type="submit" value="XLS"</form</td>**
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
"Download to Excel" isn't a tag name, so getElementsByTagName would return Nothing. Assuming the download form is the first (0) form on the page, try:
VBA Code:
ie.Document.forms(0).submit
 
Upvote 0
Tried submitting forms(0)-forms(14) without success. Forms 0-6 doesn’t invoke an error but doesn’t load another page or form. Submitting forms(7) onwards invokes error 424 object required, which I assume means there aren’t that number of forms.
 
Upvote 0
Try adding a wait loop after the second ie.Navigate:
VBA Code:
    While ie.Busy Or ie.readyState <> 4: DoEvents: Wend
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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