Skip to content

Commit

Permalink
Merge pull request #38 from sportsdataverse/pwhl_scraper
Browse files Browse the repository at this point in the history
updating documentation and package build
  • Loading branch information
benhowell71 authored Feb 26, 2024
2 parents 50c3fac + f60b198 commit 12ff24b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions R/pwhl_pbp.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @description PWHL Play-by-play
#'
#' @param game_id Game ID that you want play-by-play for
#' @return A data frame with play-by-play data
#' @return A data frame with play-by-play data from the PWHL
#' @import jsonlite
#' @import dplyr
#' @import httr
Expand All @@ -19,7 +19,8 @@ pwhl_pbp <- function(game_id) {
res <- httr::RETRY("GET", URL)
res <- res %>%
httr::content(as = "text", encoding = "utf-8")
res <- gsub("angular.callbacks._8\\(", "", res)
callback_pattern <- "angular.callbacks._\\d+\\("
res <- gsub(callback_pattern, "", res)
res <- gsub("}}])", "}}]", res)

r <- res %>% jsonlite::parse_json()
Expand Down
6 changes: 4 additions & 2 deletions R/pwhl_schedule.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ pwhl_schedule <- function(season) {

res <- res %>%
httr::content(as = "text", encoding = "utf-8")

res <- gsub("angular.callbacks._1\\(", "", res)
callback_pattern <- "angular.callbacks._\\d+\\("
res <- gsub(callback_pattern, "", res)
# res <- gsub("\\}\\]\\)$", "}}]", res)
# res <- gsub("angular.callbacks._1\\(", "", res)
res <- gsub("}}]}]}])", "}}]}]}]", res)

r <- res %>%
Expand Down
2 changes: 1 addition & 1 deletion man/pwhl_pbp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12ff24b

Please sign in to comment.