- May 17, 2017
- 783
- 466
Curious if anyone has been able to fully automate the CSV file download every 48 hours?
In my Visual Studio project, I have everything automated except having to initiate and save the download.
The Windows form has a WebBrowser control, which is logged into via code, exposing the details page where the download link is. By pressing a button on the Windows form, I have a 'downloadCSV' sub which navigates that WebBrowser object to effect the download. But like the cartoon character George Jetson, my job is too hard, having to press two buttons all day! Ideally the download should be automatic, but because my code simple presents the Windows Open/Save/Cancel dialog, human intervention is needed.
I use two DatePickers, which in code are set to the full 48 hour time span from the current time. Hope this might help anyone else who codes, but I'd like to hear of any other process to automate the collection.
Sub downloadCSV()
'https://cloud.openalpr.com/api/sear...3T12:4559-08:00&order=desc&format=csv
'start=2019-01-27T00%3A00%3A01-08%3A00&end=2019-02-03T23%3A59%3A59-08%3A00&
Dim strFullURL As String
Dim strTime1 As String
Dim strTime2 As String
'Debug.Print(dtPicker1.Value.ToString)
'2/1/2019 12:27:45 PM
strTime1 = Format(dtPicker1.Value, "yyyy-MM-dd HH:mm")
strTime2 = Format(dtPicker2.Value, "yyyy-MM-dd HH:mm")
'Debug.Print(strTimeValue)
'2019-02-01 12:31
'1234567890123456
'2019-01-27T11%3A12%3A28-08%3A00&end=2019-02-03T11%3A12%3A28-08%3A00&
'2018-01-20T00%3A00%3A00-08%3A00&end=2021-01-27T23%3A59%3A59-08%3A00&
'2019-01-27T00%3A00%3A01-08%3A00&end=2019-02-03T23%3A59%3A59-08%3A00&
strFullURL = "https://cloud.openalpr.com/api/search/group?topn=20000&start="
strFullURL = strFullURL &
Mid(strTime1, 1, 4) & "-" &
Mid(strTime1, 6, 2) & "-" &
Mid(strTime1, 9, 2) & "T" &
Mid(strTime1, 12, 2) & "%3A" &
Mid(strTime1, 15, 2) & "%3A00-08%3A00&end=" &
Mid(strTime2, 1, 4) & "-" &
Mid(strTime2, 6, 2) & "-" &
Mid(strTime2, 9, 2) & "T" &
Mid(strTime2, 12, 2) & "%3A" &
Mid(strTime2, 15, 2) & "%3A00-08%3A00&order=desc&format=csv"
wBdownload.Navigate(strFullURL)
'Debug.Print(strFullURL)
End Sub
In my Visual Studio project, I have everything automated except having to initiate and save the download.
The Windows form has a WebBrowser control, which is logged into via code, exposing the details page where the download link is. By pressing a button on the Windows form, I have a 'downloadCSV' sub which navigates that WebBrowser object to effect the download. But like the cartoon character George Jetson, my job is too hard, having to press two buttons all day! Ideally the download should be automatic, but because my code simple presents the Windows Open/Save/Cancel dialog, human intervention is needed.
I use two DatePickers, which in code are set to the full 48 hour time span from the current time. Hope this might help anyone else who codes, but I'd like to hear of any other process to automate the collection.
Sub downloadCSV()
'https://cloud.openalpr.com/api/sear...3T12:4559-08:00&order=desc&format=csv
'start=2019-01-27T00%3A00%3A01-08%3A00&end=2019-02-03T23%3A59%3A59-08%3A00&
Dim strFullURL As String
Dim strTime1 As String
Dim strTime2 As String
'Debug.Print(dtPicker1.Value.ToString)
'2/1/2019 12:27:45 PM
strTime1 = Format(dtPicker1.Value, "yyyy-MM-dd HH:mm")
strTime2 = Format(dtPicker2.Value, "yyyy-MM-dd HH:mm")
'Debug.Print(strTimeValue)
'2019-02-01 12:31
'1234567890123456
'2019-01-27T11%3A12%3A28-08%3A00&end=2019-02-03T11%3A12%3A28-08%3A00&
'2018-01-20T00%3A00%3A00-08%3A00&end=2021-01-27T23%3A59%3A59-08%3A00&
'2019-01-27T00%3A00%3A01-08%3A00&end=2019-02-03T23%3A59%3A59-08%3A00&
strFullURL = "https://cloud.openalpr.com/api/search/group?topn=20000&start="
strFullURL = strFullURL &
Mid(strTime1, 1, 4) & "-" &
Mid(strTime1, 6, 2) & "-" &
Mid(strTime1, 9, 2) & "T" &
Mid(strTime1, 12, 2) & "%3A" &
Mid(strTime1, 15, 2) & "%3A00-08%3A00&end=" &
Mid(strTime2, 1, 4) & "-" &
Mid(strTime2, 6, 2) & "-" &
Mid(strTime2, 9, 2) & "T" &
Mid(strTime2, 12, 2) & "%3A" &
Mid(strTime2, 15, 2) & "%3A00-08%3A00&order=desc&format=csv"
wBdownload.Navigate(strFullURL)
'Debug.Print(strFullURL)
End Sub