Schedule this program to run at whatever interval you like. It creates a folder for Year and Month. It then saves the statistical information in a CSV file via the name of the day.
To change what URL you are accessing and the file to save it as, edit the config.txt file 🙂
It records the poll time and the time in milliseconds it took to load the file…wwwwwwweeeeeeeeeee
Download compiled files here:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; Advanced example - downloading in the background
#include <file.au3>
$timer = 0
$timeout = 0
;open config.txt and load our page and file name
Dim $aConfig
If Not _FileReadToArray(@ScriptDir & "\config.txt",$aConfig) Then
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
$URL = $aConfig[1]
$File = $aConfig[2]
;create our output folders.
DirCreate(@ScriptDir & "\" & @YEAR)
DirCreate(@ScriptDir & "\" & @YEAR & "\" & @MON)
;pull file
Local $hDownload = InetGet($URL, @ScriptDir & "\" & $File, 1, 1)
Do
$timer = $timer + 5
Sleep(5)
if $timer > 40000 Then
;ran over 40 seconds kill it.
$timeout = 1
_WriteFile()
Exit
EndIf
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resourcs.
_WriteFile() ;call function to write file.
Func _WriteFile()
$fData = FileOpen(@ScriptDir & "\" & @YEAR & "\" & @MON & "\" & @MDAY & ".csv", 1)
; Check if file opened for writing OK
If $fData = -1 Then
MsgBox(0, "Error", "Unable to open file. Make sure excel doesn't have it open.", 5)
Exit
EndIf
if $timeout == 0 Then
FileWriteLine($fData, @HOUR & ":" & @MIN & ":" & @SEC & "," & $timer & @CRLF)
Else
FileWriteLine($fData, @HOUR & ":" & @MIN & ":" & @SEC & ",timeout" & @CRLF)
EndIf
FileClose($fData)
EndFunc
Leave a Reply