Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including Fangraphs Player ID with Leaderboard Scrape #61

Closed
jestarr opened this issue Apr 13, 2018 · 18 comments
Closed

Including Fangraphs Player ID with Leaderboard Scrape #61

jestarr opened this issue Apr 13, 2018 · 18 comments

Comments

@jestarr
Copy link

jestarr commented Apr 13, 2018

Is there anyway that this can be included in the data scrape as a part of the data frame?

@BillPetti
Copy link
Owner

So, it used to be there, but looking at the url structure they changed it--basically because there are a ton more fields available. So, yes, but I'll need to update the url and subsequent formatting used in the function.

@BillPetti BillPetti self-assigned this Apr 13, 2018
@jestarr
Copy link
Author

jestarr commented Apr 13, 2018

Perfect. Is the pitcher leaderboard scrape coming soon?

@BillPetti
Copy link
Owner

playerid will be added in the next package update. No plans right now for the pitcher leader board, but if someone wanted to tackle it in a pull request that would be groovy.

@jestarr
Copy link
Author

jestarr commented May 30, 2018

Did the fgid make it into this package?

@BillPetti
Copy link
Owner

Yes

@jestarr
Copy link
Author

jestarr commented May 30, 2018

I didn't see it when I ran it, and also didn't see it in the code. Not sure if I did something wrong on my end.

@BillPetti
Copy link
Owner

It was there when I tested it. I’ll double check later.

@BillPetti BillPetti reopened this May 30, 2018
@BillPetti BillPetti added the bug label May 30, 2018
@jestarr
Copy link
Author

jestarr commented Oct 11, 2018

Any updates on this bug?

@stevebit
Copy link

stevebit commented Mar 9, 2019

Any updates on the bug. I just ran the function and didn't get the id.

@BillPetti BillPetti added help wanted and removed bug labels Mar 9, 2019
@BillPetti
Copy link
Owner

Unfortunately, this is not so much a bug as an enhancement. The data needs to pull retrieved in a different way to get the playerid returned with the leaderboards. I have not worked out an approach yet.

@BillPetti
Copy link
Owner

So looking this over, I should be able to extract playerid from the url for each player from the html of the page. Just need to find some time to do it.

@stevebit
Copy link

stevebit commented Mar 9, 2019

That would be very cool. Unfortunately my programming skills aren't nearly as good as yours or I would offer to help.

@jestarr
Copy link
Author

jestarr commented Mar 11, 2019

Without doing a full fork, and PR, how about something like?

    find_possible_playerids <- leaders %>% html_nodes("a") %>% as.character()
    find_playerids <- find_possible_playerids[grep("statss.aspx\\?playerid=", find_possible_playerids)]
    find_playerids_split <- strsplit(find_playerids, "\\&") %>% sapply(., "[", 1)
    fangraphs_pg_playerids <- gsub("[[:alpha:]]*[[:punct:]]*[[:space:]]*", "", find_playerids_split)

@BillPetti
Copy link
Owner

BillPetti commented Mar 11, 2019

This should be fixed now with the latest commit. Give it a reinstall and let me know if it brakes.

@stevebit
Copy link

I just reinstalled and tested it but didn't get the playerid field. I reinstalled using,
devtools::install_github("BillPetti/baseballr")

@BillPetti
Copy link
Owner

Check and make sure your function’s content includes the new playerid code. You may need to force the install to get the updated version, install_github(“BillPetti/baseballr”, force = TRUE).

@stevebit
Copy link

Great, I got it working, everything looks good.

Separate question. Is there anyway to get a playid for the following function. daily_batter_bref() ? We get the names but it's difficult to match the names to an MLBID.

Cheers,

@BillPetti
Copy link
Owner

Probably, but please open a separate issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants