Прямо сейчас они так, как я извлекаю данные со страницы, используя r, занимает где-то 30-50 секунд для каждой игры. Есть ли другой способ, которым я мог бы сделать это и сократить время ожидания? Вытащив данные со старого сайта на основе xml, я смог вытащить игры предыдущих дней примерно за пару минут.
Любые идеи / помощь с благодарностью! Спасибо!
url = "http://statsapi-prod-alt-968618993.us-east-1.elb.amazonaws.com/api/v1/game/565711/playByPlay"
#if(GET(url)$status_code==200) chk = chk + 1
#if (chk == 10) break()
if(GET(url)$status_code!=200) next
reposLoL <- fromJSON(url, simplifyDataFrame = FALSE)
repos <- as.Node(reposLoL)
if(length(repos$scoringPlays) == 39 &&
length(repos$allPlays) == 39 &&
length(repos$playsByInning) == 39) next
#convert this to a data.frame
pitchDetails <- repos %>% ToDataFrameTable(
#game_pk = '', #substr(url, 84, 89),
type = function(x) x$type,
#isPitch = function(x) x$isPitch,
atBatNum = function(x) x$about$atBatIndex,
pitchNumber = function(x) x$pitchNumber,
pitchCalled = function(x) x$details$call$code,
pitchDesc = function(x) x$details$description,
pitchType = function(x) x$details$type$code,
pitchTypeDesc = function(x) x$details$type$description,
countStrikes = function(x) x$count2$strikes,
countBalls = function(x) x$count2$balls,
countOuts = function(x) x$count2$outs,
startSpeed = function(x) x$pitchData$startSpeed,
endSpeed = function(x) x$pitchData$endSpeed,
nastyFactor = function(x) x$pitchData$nastyFactor,
strikeZoneTop = function(x) x$pitchData$strikeZoneTop,
strikeZoneBottom = function(x) x$pitchData$strikeZoneBottom,
zone = function(x) x$pitchData$zone,
aX = function(x) x$pitchData$coordinates$aX,
aY = function(x) x$pitchData$coordinates$aY,
aZ = function(x) x$pitchData$coordinates$aZ,
pfxX = function(x) x$pitchData$coordinates$pfxX,
pfxZ = function(x) x$pitchData$coordinates$pfxZ,
pX = function(x) x$pitchData$coordinates$pX,
pZ = function(x) x$pitchData$coordinates$pZ,
vX0 = function(x) x$pitchData$coordinates$vX0,
vY0 = function(x) x$pitchData$coordinates$vY0,
vZ0 = function(x) x$pitchData$coordinates$vZ0,
X = function(x) x$pitchData$coordinates$x,
Y = function(x) x$pitchData$coordinates$y,
x0 = function(x) x$pitchData$coordinates$x0,
y0 = function(x) x$pitchData$coordinates$y0,
z0 = function(x) x$pitchData$coordinates$z0,
breakAngle = function(x) x$pitchData$breaks$breakAngle,
breakLength = function(x) x$pitchData$breaks$breakLength,
breakY = function(x) x$pitchData$breaks$breakY,
spinRate = function(x) x$pitchData$breaks$spinRate,
spinDirection = function(x) x$pitchData$breaks$spinDirection,
LaunchSpeed = function(x) x$hitData$launchSpeed,
launchAngle = function(x) x$hitData$launchAngle,
totalDistance = function(x) x$hitData$totalDistance,
batter = function(x) x$matchup$batter$id,
pitcher = function(x) x$matchup$pitcher$id,
splitsBatter = function(x) x$matchup$splits$batter,
splitsPitcher = function(x) x$matchup$splits$pitcher,
splitsMenOnBase = function(x) x$matchup$splits$menOnBase,
hasReview = function(x) x$details$hasReview
)