Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (id in pitchIDs$playerid) {
- url <- paste("https://www.fangraphs.com/statsd.aspx?
- playerid=",id,"&position=P&type=&gds=&gde=&season=all")
- gamelogs <- url %>%
- read_html() %>%
- html_nodes(xpath = '//*[@id="DailyStats1_dgSeason1_ctl00"]') %>%
- html_table()
- gamelogs$id <- id
- }
- data = c()
- for(id in pitchIDs$playerid) {
- url <- read_html(paste0("https://www.fangraphs.com/statsd.aspx?
- playerid=",id,"&position=P&type=&gds=&gde=&season=all"))
- gamelogs <- url %>%
- html_nodes(xpath = '//*[@id="DailyStats1_dgSeason1_ctl00"]') %>%
- html_table()
- gamelogs <- gamelogs[[1]]
- gamelogs$id <- id
- if(is.data.frame(data)) {
- names(gamelogs) = names(data)
- data = rbind(data, gamelogs)
- } else {
- data = gamelogs
- }
- }
Add Comment
Please, Sign In to add comment