rony2006 Posted October 24, 2017 Share Posted October 24, 2017 Hello, I have a problem using InetGet for downloading a report from a site. The problem is that report is generated each time based on url parameters (startdate and endtime). Here is the url: http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_RTPD_LMP&startdatetime=20171024T15:00- 0000&enddatetime=20171025T00:00-0000&version=1&market_run_id=RTPD&node=TJI-230_2_N101 Here is the code that I use: ; Save the downloaded file to the temporary folder. Local $sFilePath = @ScriptDir & "/raport1.zip" $StartDate = StringReplace(_NowCalcDate(),"/", "") ;Msgbox(0, "StartDate", $StartDate) Local $sNewDate = _DateAdd('d', 1, _NowCalcDate()) $EndDate = StringReplace($sNewDate,"/", "") ;Msgbox(0, "StartDate", $EndDate) ; Download the file in the background with the selected option of 'force a reload from the remote site.' Local $hDownload = InetGet("http://oasis.caiso.com/oasisapi/SingleZip?resultformat=6&queryname=PRC_RTPD_LMP&startdatetime=" & $StartDate &"T15:00-0000&enddatetime=" & $EndDate &"T00:00-0000&version=1&market_run_id=RTPD&node=TJI-230_2_N101", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do Sleep(1000) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize($sFilePath) ; Close the handle returned by InetGet. InetClose($hDownload) msgbox(0, "", "stop") sleep(10000) The problem is that sometimes the generation of report is taking about 40-60 seconds and my script doesn't care about : Do Sleep(1000) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) How I can solve this problem please? Link to comment Share on other sites More sharing options...
EmilyLove Posted October 24, 2017 Share Posted October 24, 2017 Can you clarify the issue? I don't understand what you are wanting. What are you expecting it to do and what is it actually doing instead. Link to comment Share on other sites More sharing options...
rony2006 Posted October 24, 2017 Author Share Posted October 24, 2017 I expect that I get a .zip file downloaded in script dir using the above code. caiso.com can generate any report, in a .zip file based on the values that url contains. The problem is that sometimes after you manually access the url, the downloading process doesn't start quick. Usually it takes 20-30 seconds until download starts. My script is working but some of the time, it didn't waits until caiso.com generates the report. So my code jumps directly at msgbox(0, "", "stop") and I don't get any file downloaded in my script dir. Link to comment Share on other sites More sharing options...
EmilyLove Posted October 24, 2017 Share Posted October 24, 2017 Got it. Away from PC atm, when i get back, ill post some example code. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now