OpenALPR 48 Hour CSV Collection?

DLONG2

Known around here
Joined
May 17, 2017
Messages
763
Reaction score
454
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/search/group?topn=20000&start=2019-02-01T12:4500:8-08:00&end=2019-02-03T12:4559-08:00&order=desc&format=csv
'start=2019-01-27T00%3A00%3A01-08%3A00&end=2019-02-03T23%3A59%3A59-08%3A00&amp


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&amp
'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&amp


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
 

Attachments

MachAF

Young grasshopper
Joined
Dec 12, 2018
Messages
49
Reaction score
23
Location
Washington
I think the easiest solution would be to setup a crontab to download it automatically every 48 hours. I've researched it a bit, but haven't put in the time to totally figure it out.

Next setup would be to have the csv data pushed to a SQL database... Then have some PHP code to search the data base.
 

DLONG2

Known around here
Joined
May 17, 2017
Messages
763
Reaction score
454
I have the database and the queries running fine. With the periodic download of the CSV file, though, their webserver denies access except from within their web page, which needs to be logged into. In my project, I have a hidden WebBrowser control automatically logged into. The last step is to get the darn file to download without any manual intervention. I got it to work with SendKeys, but that is not an elegant solution, as it requires the popup 'File Download' dialog window to have focus, and I don't want to be sending a bunch of Tab and Enter keys without assurance the process will work 100%. Been looking into the 'FindWindow' API call at this point. If you can get a crontab to automate the download I would appreciate hearing about it.

Here's the download URL for the past 48 hours from now:
https://cloud.openalpr.com/api/search/group?topn=20000&start=2019-04-14T18:33:00-08:00&end=2019-04-16T18:33:00-08:00&order=desc&format=csv

The link above works fine on my OpenALPR PC, but not on another PC, as the server returns: "Authentication not provided'. But seeing this gives me an idea, because I didn't get the 'File Download' dialog, it just came to my Downloads folder. . . .
 
Last edited:
Top