I need to download file behind login screen, is it possible to handle download using IE COM?
Code: Select all
;... create new Internet Explorer
pwb := ComObjCreate("InternetExplorer.Application")
pwb.Visible := False
;... go to login page
pwb.Navigate("http://www.example.com/login")
;... wait for page to load
Sleep, 100
while pwb.busy or pwb.ReadyState != 4
Sleep, 100
;... log me into website
pwb.document.all.email.Value :="example@example.com" ;set ID - email
pwb.document.all.password.Value :="password123" ;set ID - password
;... go to download page
pwb.Navigate("http://www.example.com/downloads")
;... wait for page to load
Sleep, 100
while pwb.busy or pwb.ReadyState != 4
Sleep, 100
;... Click Download button
pwb.document.all.tags("SPAN")[41].click()
https://social.microsoft.com/Forums/getfile/12584/
Is it possible to download and save file (it is .csv file), when Internet Explorer is hidden?
I have tried UrlDownloadToFile - does not work, because I need to be logged in to download file
I have tried this script - https://stackoverflow.com/questions/294 ... loadtofile - At first it worked, but the session cookie expires after 30 minutes and download link changes too.
Thank you for your time.
EDIT:
Fixed it using this script - https://stackoverflow.com/questions/294 ... loadtofile
I got referer from IE using
Code: Select all
pwb.LocationURL
Code: Select all
pwb.document.cookie
Code: Select all
customHeaders := {"User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
,"Cache-Control": "max-age=0"
,"Referer": pwb.LocationURL
,"Cookie": pwb.document.cookie}
Download(GeneratedDownloadLink,outputCSVFile,True,customHeaders,"GET")