Skip to content

Commit

Permalink
updated example tests and hockeyref player scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
danmorse314 committed Nov 13, 2023
1 parent ff8ba4a commit b49e80a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
6 changes: 4 additions & 2 deletions R/get_game_shifts.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#' @export
#'
#' @examples
#' \dontrun{
#' get_game_shifts(2020020561)
#' \donttest{
#' try({
#' get_game_shifts(game_id = 2023020201)
#' })
#' }
get_game_shifts <- function(game_id){

Expand Down
15 changes: 11 additions & 4 deletions R/get_player_stats_hr.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#' @export
#'
#' @examples
#' \dontrun{
#' #' get_player_stats("Wayne Gretzky")
#' get_player_stats_hr(c("Wayne Gretzky","Mario Lemieux"))
#' \donttest{
#' try({
#' get_player_stats_hr("Connor Bedard")
#' })
#' }
get_player_stats_hr <- function(player_name, season = "career", league = "NHL"){

Expand Down Expand Up @@ -46,7 +47,13 @@ get_player_stats_hr <- function(player_name, season = "career", league = "NHL"){
}

player <- session %>%
rvest::html_element("table")
rvest::html_element("#stats_basic_plus_nhl")

# check for missing table
if(length(player) == 0){
player <- session %>%
rvest::html_element("#stats_basic_nhl")
}

# skip players with no stats
# likely linking to wrong player
Expand Down
6 changes: 4 additions & 2 deletions R/scrape_game.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@
#' @export
#'
#' @examples
#' \dontrun{
#' pbp <- scrape_game(2020020420)
#' \donttest{
#' try({
#' pbp <- scrape_game(game_id = 2023020201)
#' })
#' }
scrape_game <- function(game_id){

Expand Down
4 changes: 3 additions & 1 deletion man/get_game_ids.Rd

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

0 comments on commit b49e80a

Please sign in to comment.