Hi,
I have a script that can login to a site and download a file. It needs keystrokes ( ctrl J - to get VIEW DOWNLOADS ) though and often the keystrokes do not work correctly (the "view downloads" window does not come up). So i am looking for an alternate approach to login and download the file.
I am able to login to the site. Once done I get a handle to MSIE.
I can use this handle to download the webpage with:
FilePut((File_PageCheck), msie.document.GetElementsByTagName("HTML").item(0).outerHTML)
.. but i need to download a CSV file from the site, which is something I cannot currently do via script.
I was thinking that since I have a handle to MSIE i can get the URL link of the CSV file on the page and download it.
To make it more difficult the csv file is referenced as a URL on the page (https://www.lendingclub.com/foliofn/notesRawData.action) and once you click on the URL it will download the CSV file
In the past I have used WWINT (to download a file /image) but this will not work as the site needs to be logged into.
tophandle=iBegin(0,"","")
....
Any ideas?
Here is my script:
url_Note = "https://www.lendingclub.com/foliofn/tradingInventory.action"
lc_Login = "admin@yahoo.com"
lc_pass = "admin123"
File_PageCheck = "c:\temp\File_PageCheck.txt"
GoSub Open_IE
exit
:Open_IE
msie = ObjectOpen("InternetExplorer.Application")
msie.Visible = @True
msie.Navigate(url_Note)
GoSub WaitForMSIE
GoSub Login_LCAccount
GoSub GetMSIE
FilePut((File_PageCheck), msie.document.GetElementsByTagName("HTML").item(0).outerHTML); get the HTML content to file
Return
:GetMSIE
msie = 0
Shell = ObjectOpen("Shell.Application")
For x = 0 To Shell.Windows.count-1
ErrorMode(@OFF)
swi = Shell.Windows.item(x)
If !swi
ErrorMode(@CANCEL)
Continue
EndIf
swif = Shell.Windows.item(x).fullname
If !StrIndexNC(swif, "iexplore.exe", 1, @FWDSCAN)
ErrorMode(@CANCEL)
Continue
EndIf
msie=Shell.Windows.item(x)
URL = msie.LocationURL
ErrorMode(@CANCEL)
Break
Next
Return
:WaitForMSIE
while msie.busy
MsieBusy = msie.busy
endwhile
Return
:Login_LCAccount
objEvent = msie.document.createEvent("HTMLEvents") ; needed for compatability mode
InputCollection = msie.document.GetElementsByTagName("INPUT")
ForEach Input In InputCollection
if input.name == "login_email" THEN input.value = lc_Login
if input.name == "login_password" THEN input.value = lc_Pass
if input.id == "master_accountSubmit" THEN
If objEvent == "" Then ; needed for compatability mode
Input.click
Else
objEvent.initEvent("click", @true, @true)
Input.dispatchEvent(objEvent)
Timedelay(2)
EndIf
Break
endif
Next
Return