Created
May 28, 2019 16:48
-
-
Save mrchypark/86670c4b5d6c62e79f35357e0c0fcd35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(httr) | |
library(magrittr) | |
library(dplyr) | |
library(stringr) | |
library(jsonlite) | |
tar <- "https://www.pubgesports.kr/front/team/roundChange?matchApiId=954976a0-b74d-4c2a-9ddf-6c1b7e8cac84&leagueNo=13&teamNo=4" | |
GET(tar) %>% | |
content("text") %>% | |
str_split(fixed("}{")) %>% | |
.[[1]] %>% | |
.[1] %>% | |
paste0("}") %>% | |
fromJSON() %>% | |
.$statList %>% | |
as_tibble() %>% | |
select(playerId, | |
kills, | |
damage, | |
revive, | |
distance, | |
timeSurvived, | |
longestKill, | |
heals, | |
boosts) | |
tar <- "https://www.pubgesports.kr/front/team/detail?teamNo=4&leagueNo=13" | |
GET(tar) %>% | |
content() %>% | |
html_nodes("ul.teamRound li a") %>% | |
html_attr("data-match-api") -> | |
match_id | |
library(purrr) | |
match_data <- function(match_id){ | |
str_c("https://www.pubgesports.kr/front/team/roundChange?leagueNo=13&teamNo=4&matchApiId=", match_id) %>% | |
GET() %>% | |
content("text") %>% | |
str_split(fixed("}{")) %>% | |
.[[1]] %>% | |
.[1] %>% | |
paste0("}") %>% | |
fromJSON() %>% | |
.$statList %>% | |
as_tibble() %>% | |
select(playerId, | |
kills, | |
damage, | |
revive, | |
distance, | |
timeSurvived, | |
longestKill, | |
heals, | |
boosts) | |
} | |
library(hms) | |
match_id %>% | |
map_dfr( ~ match_data(.x) %>% | |
mutate( | |
match_id = .x, | |
timeSurvived = hms::parse_hms(str_c("00:", timeSurvived)) | |
)) %>% | |
select(match_id, everything()) -> | |
dat | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment