I’m writing a script which gathers the Totals for Aircraft Reported and Positions Reported, for a number of different sites, and performs some mathematical analysis, essentially using nearby sites as a baseline for assessing site changes. I’m referring to these numbers highlighted in red.
I just want the numbers in some delimited form so they can be parsed and stored in arrays for use. For example for the first example above I want something like
128,1481,1446,1549,...
or perhaps
128
1481
1446
1549
...
As a PiAware feeder with an Enterprise account, I’m wondering if there is a way to get these via an API call or some official method? I’ve scoured around and not found anything.
The approach I’m currently looking at involves grabbing the unprocessed HTML, extracting the script JSON with plenty of grep and sed, and running it through jq to get the unprocessed numbers in list form. I’ve not perfected the magical incantations needed but it’s almost there
I’ve completed the script which extracts the Totals from the stats page. See the README for how to use.
With these numbers now available in this format they can then be used in a script for further analysis. I’m not aware of any API which provides these totals, so this approach seems like the only way to get them.
Thanks for doing this work, and for your explanation!
For others, I thought this was really cool, but it didn’t do everything that I hoped it would. I made some changes that the author (for good reason) doesn’t want to merge into the main code, so I am offering my fork in case anyone has a similar use case.
Everything that I changed from the original is optional and defaulted to ‘off’. So out of the box it will operate in the same way as the original code.
I started out making a change because I wanted to use a comma as a delimiter rather than a space, and then realized that others might want to use some other character, so I made it a variable that users could edit.
Then I decided that it would be useful to write the data to a file that I could import straight into a spreadsheet, so I created an option to output to screen as originally written, or to a text file (added variable for file name), or to both. In either of those cases, it will append data to the existing file if it exists, or create on if it doesn’t. Finally, I thought it would be helpful to include the date row, so I added that in as well - but again, made it optional.
As far as I can tell, I have the defaults set so that out of the box the version with my edits works exactly the same as the original. There are just more options now.
I am thinking about running this monthly as a cron job so I also added an option to use a date/time-based unique file name.