Open thecruncherau opened 1 year ago
This would be great.
Thanks for the message and it's something I've looked into in the past but have always put to the side for similar reasons you suggest above.
I'd be more than open to a PR if you had a working example. Even if it's just a starting point of getting the actual results for one match, we could then look at some kind of general approach for thinking about finding a specific match
I believe there is also an API for the AFL Website that has all the required information to do a score progression worm as well.
library(httr)
library(jsonlite)
headers = c(
'x-media-mis-token' = fitzRoy:::get_afl_cookie()
)
res <- GET(url = "https://api.afl.com.au/cfs/afl/matchItem/CD_M20230141903", add_headers(headers))
match_info <- parse_json(content(res, 'text', encoding = "UTF-8"))
With some further wrangling the information contained in match_info$score$scoreWorm
and match_info$score$matchClock
would be sufficient to construct score worm data (the latter for providing the length of quarters if that is part of your logic).
This api also has a bunch of other handy information about matches such as weather.
There doesn't appear to be any score progression data within {fitzRoy} currently, so it might be a welcomed feature if it were to be included. Contributing this myself would be something I'd be interested in working on.
A possible problem with this is efficiency - replicating AFLTables' own match id system for scraping relies on knowing all teams involved in the season in question. Additionally, it's only possible to scrape one at a time and therefore, discouraging scraping of many matches in some way would be ideal.
Another concern is matching ids. The ids in the big list, scraped in
fetch_results_afltables()
, use a simple chronological index and it's not possible to derive this index from an individual match centre page alone.Looking forward to hearing your thoughts on this.